Basic Docker Notes
To run a container from an image:
|
|
-t
: terminal inside
-i
: (STDIN) grabbing
--rm
: remove container automatically when process exits
--name
: name the container or daemon
-d
: daemonize the container running
To list all containers:
|
|
To start or stop container:
|
|
To remove container(s):
|
|
-q
: print only container IDs
To run a container as a daemon:
|
|
-p
: port mapping, host_port:container_port
-v
: volume mounting, host_dir:container_dir
$(pwd)
: current working dir
To check the information of a resource(container or image or volume or network):
|
|
To write a basic Dockerfile:
To build an image from Dockerfile:
|
|
.
: means context is the current working directory.
-t
: sets a name for the image
For accessing to the docker daemon as a non-root user:
Remove all unused(dangling) build cache:
|
|
Rule of thumb
- 1 app = 1 container
- Process should be running in the foreground
- Keep data in volumes, not in containers
- Do not use SSH, use
docker exec
instead - Avoid manual configurations inside container
Happy containerizing! 🙂