Skip to content

Docker

docker run optionsπŸ”–

Environment variablesπŸ”–

Specify as many environment variables as you like with the -e option

docker run -e API_HOST="http://api:8000" -e API_USERNAME="badman" ...

VolumesπŸ”–

docker run -v /local/path:/docker/path --rm docker-image-name command
If the command is an interactive processes (like a shell), you must use -i -t together in order to allocate a tty for the container process.

LogsπŸ”–

Follow logs of a running docker instance

docker logs -f container-name

Clean upπŸ”–

Remove unused containers, networks, images etc

docker system prune

Official Docker system prune reference

docker-composeπŸ”–

Start a single service from a compose file, exposing the port 8000 that the webserver uses so it is accessible from the host.

docker-compose run --rm -p 8000:8000 --name web web python manage.py runserver 0.0.0.0:8000

ResourcesπŸ”–

JΓ©rΓ΄me Petazzoni on docker build patterns