Docker intro
More
CMD, ENTRYPOINT
https://medium.freecodecamp.org/docker-entrypoint-cmd-dockerfile-best-practices-abc591c30e21
./entrypoint.sh
https://www.youtube.com/watch?v=4EqysCR3mjo
Build and run multi-container apps. One form is Docker Compose file, also docker-compose command.
entrypoint: /entrypoint.shCMD (Dockerfiles) / command (Docker Compose files)
https://docs.docker.com/compose/overview/
Docker compose files, "network". Can only run docker compose on single machine. Swarm is the orchestration solution provided by docker. (cluster)
docker-compose builddocker-compose up -ddocker network ls
Refer to the container by the name of the service
Secrets are used in Docker Swarm
dockerfile option within docker-compose build section
docker-compose psdocker-compose logs -fdocker-compose stop# does not remove containersdocker-compose startdocker-compose restart
Execute redis query on redis-cli, from within docker redis
docker-compose exec redis redis-cli lrange students 0 -1docker-compose exec app /bin/bash# start up a shelldocker-compose run...# starts up a new container, as opposed to exec uses a running container
Port mapping will not be intact in this case
Can change port mapping, e.g. from 5000:5000 to 80:5000, and do another docker-compose up and everything is updated.
Can do a curl localhost and get the desired response on port 80
Scaling
Start more than one container for a service
docker-compose up --scale app=3
Volumes
docker volume ls
Networks
docker network lsdocker network prune
Docker compose push to push to a repository
Docker compose pull to download all the images necessary. (Docker playground)
.env file
How to use multiple compose files in a single project
e.g. docker-compose.override.yml
e.g. make it run on port 5000 and port 80