Docker Review Note
webserver → DB → messaging → orchestration
- the architecture of these components are varying over time!
- setting environment is painful!
- development team members have different OS environment
- Container utilize the same OS Kernel (handling with hardware), which differs from VM
some Commands I don’t know:
docker pull <image>only pull image from DockerHub to local
docker exec <container name> <command>
docker run -drun in detach
docker run -it centos bashrun a base image and gets into bash
docker attach <container name>run some detached app in foreground
docker run redis:4.0specify a tag
docker run -itruns interactively with terminal
docker run -v /opt/datadir:/var/lib/mysql mysqlmount volume
docker logs <container name>logs out the container status
docker run ubuntu cat /etc/*release*run a command of a ubuntu image and exit container
docker attach <container name>pull a container to foreground
docker build <Dockerfile name> -t <xxx/xxxx>build an image
docker push <xxx/xxx>push a docker image to dockerhub
cat > Dockerfileinput to a file
docker run -e <ENV NAME>=<ENV VALUE> <image name>set a environement variable
docker inspect <container name>
¶CMD V.S Entrypoint
CMD simply refers to run a command
ENTRYPOINT allows us to append further params to
ENTRYPOINT means that the user can interrupt the flow of
Dockerfile and input some params into it.
We can also overwrite ENTRYPOINT by
If we do not want Docker to pull images from dockerhub, we can replace
docker-compose.yml so that it knows to build the image from local
Docker engine is composed of :
- Docker CLI
- REST API
- Docker Deamon
Docker uses namespace to differentiate main system and child system
cgroups can be used to ensure the limit of CPU usages
docker run --cpus=0.5 ubuntu
docker run --memory=100m ubuntu
We can view docker files at
Docker uses layered architecture
In the container layer, all files are writeable, however. Files on image layers are not writable. But we can copy them into the container layer and change them, but we need to rebuild the image then.
mount a piece of memory to a named volume, different containers can share this volume
mount a folder location to a folder location in the container.
bridgeis the default network
noneis an isolated network
hostis a direct mapping with the host network
docker network createcreate new user-defined network
- Docker has DNS setting so that a container name is directly mapped with the container IP!
A solution to host multiple containers at the same time.
- Docker Swarm