Appearance
Tips: Docker
docker start/run/create
docker run
= create + start + attach
= create + ( start -a )
= ( run --detach ) + attach
docker compose up/start
docker compose up
= build + (up --no-start) + start
= build + create + start
docker compose down
= stop + rm [ + docker network rm ... ]
docker compose down -v
= down + docker volume rm ...
ENTRYPOINT vs CMD
entrypoint is the "entry" base command. It is the "app" that the image represents. If it does not represent an app, it should be empty.
cmd is the default argument(s) to the entrypoint. If entrypoint does not exist, cmd gets executed. cmd can be overridden.
For example:
Dockerfile
ENTRYPOINT ["python", "app.py"]
CMD ["default_arg1", "default_arg2"]
https://stackoverflow.com/a/34245657
Invoke docker without sudo
Invoke docker
without adding sudo
every time.
You still need root permission to configure this.
sh
sudo usermod -aG docker $(whoami)
# Re-login
https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user
docker compose restart
Restart docker compose with updated images.
sh
docker compose pull
docker compose up -d
docker compose logs -f
If there are existing containers for a service, and the service’s configuration or image was changed after the container’s creation,
docker compose up
picks up the changes by stopping and recreating the containers (preserving mounted volumes). To prevent Compose from picking up changes, use the--no-recreate
flag.https://docs.docker.com/engine/reference/commandline/compose_up/#description