Docker Build

less than 1 minute read

Build Docker Image & run, start, stop and exit container

  • by using shell command
    $ bash docker/build.sh
    
  • or by using dockerfile directly
    $ docker build Dockerfile
    
  • After built, run docker.(tagged_name: Image name)
    $ docker run tagged_name
    
  • start container
    $ docker container start container_id
    
  • access to bash shell
    $ docker exec -it container_id bash
    
  • stop docker container
    $ docker stop container_id
    
  • exit docker container in interactive responsive shell
    ctrl + d
    
  • stop all running containers
    $ docker stop $(docker ps -a -q)
    
  • Show docker disk usage
    $ docker system df
    

Keep running Docker container

  • add ENTRYPOINT in Dockerfile as last line.
    ENTRYPOINT ["tail", "-f", "/dev/null"]
    

ref: https://devopscube.com/keep-docker-container-running/

Docker ENTRYPOINT Instruction

ENTRYPOINT ["tail", "-f", "/dev/null"] ๋กœ ํ•ด์•ผ keep running.

tail : ๋งจ๋’ค์— ๋‹ค์„ฏ์ค„ ๋ณด์—ฌ์คŒ
-f : ํ”ผ๋“œ๋ฅผ ๊ณ„์† ์ฝ์–ด์คŒ
/dev/null: null ์„ ๊ณ„์† ์ฝ์–ด์คŒ

For the future work.

Never write latest on the file name in any enviroment related files.

Write very specific version on every files in use for compatibility.

Leave a comment