https://github.com/andyatkinson/my_web_app
Learning docker and docker compose
https://github.com/andyatkinson/my_web_app
docker docker-compose python
Last synced: 2 months ago
JSON representation
Learning docker and docker compose
- Host: GitHub
- URL: https://github.com/andyatkinson/my_web_app
- Owner: andyatkinson
- Created: 2019-03-01T20:23:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-19T21:37:58.000Z (over 6 years ago)
- Last Synced: 2025-10-28T12:31:29.859Z (8 months ago)
- Topics: docker, docker-compose, python
- Language: Dockerfile
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Docker intro
More
CMD, ENTRYPOINT
`./entrypoint.sh`
## Docker Compose
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.sh`
* `CMD (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 build`
* `docker-compose up -d`
* `docker 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 ps`
* `docker-compose logs -f`
* `docker-compose stop` # does not remove containers
* `docker-compose start`
* `docker-compose restart`
## Execute redis query on redis-cli, from within docker redis
* `docker-compose exec redis redis-cli lrange students 0 -1`
* `docker-compose exec app /bin/bash` # start up a shell
* `docker-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 ls`
* `docker 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