An open API service indexing awesome lists of open source software.

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

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