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