Docker Compose – How to execute multiple commands?

Figured it out, use bash -c. Example: command: bash -c “python manage.py migrate && python manage.py runserver 0.0.0.0:8000” Same example in multilines: command: > bash -c “python manage.py migrate && python manage.py runserver 0.0.0.0:8000″ Or: command: bash -c ” python manage.py migrate && python manage.py runserver 0.0.0.0:8000 “

What is the difference between docker-compose ports vs expose

According to the docker-compose reference, Ports is defined as: Expose ports. Either specify both ports (HOST:CONTAINER), or just the container port (a random host port will be chosen). Ports mentioned in docker-compose.yml will be shared among different services started by the docker-compose. Ports will be exposed to the host machine to a random port or … Read more

How to list containers in Docker

To show only running containers use the given command: docker ps To show all containers use the given command: docker ps -a To show the latest created container (includes all states) use the given command: docker ps -l To show n last created containers (includes all states) use the given command: docker ps -n=-1 To … Read more

How to remove old and unused Docker images

(original answer see below) Update Sept. 2016: Docker 1.13: PR 26108 and commit 86de7c0 introduce a few new commands to help facilitate visualizing how much space the docker daemon data is taking on disk and allowing for easily cleaning up “unneeded” excess. docker system prune will delete ALL dangling data (i.e. In order: containers stopped, … Read more

How to deal with persistent storage (e.g. databases) in Docker

Docker 1.9.0 and above Use volume API docker volume create –name hello docker run -d -v hello:/container/path/for/volume container_image my_command This means that the data-only container pattern must be abandoned in favour of the new volumes. Actually the volume API is only a better way to achieve what was the data-container pattern. If you create a … Read more

How do I pass environment variables to Docker containers?

You can pass environment variables to your containers with the -e flag. An example from a startup script: sudo docker run -d -t -i -e REDIS_NAMESPACE=’staging’ \ -e POSTGRES_ENV_POSTGRES_PASSWORD=’foo’ \ -e POSTGRES_ENV_POSTGRES_USER=’bar’ \ -e POSTGRES_ENV_DB_NAME=’mysite_staging’ \ -e POSTGRES_PORT_5432_TCP_ADDR=’docker-db-1.hidden.us-east-1.rds.amazonaws.com’ \ -e SITE_URL=’staging.mysite.com’ \ -p 80:80 \ –link redis:redis \ –name container_name dockerhub_id/image_name Or, if you don’t … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)