Docker Cheatsheet

Start a container when using Docker Compose

docker-compose up -d

Stop a container

docker stop container_name

List all images

docker images -a

Removing containers

See: https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes

Executing commands on services within the container

docker-compose exec <service> <command>

For example:

docker-compose exec app php artisan key:generate

docker-compose exec: tells docker to execute something in the container
app: name of the service as defined in docker-compose.yml
php artisan key:generate: command to execute in the container, just as you would normally run on your local machine

Another example:

docker-compose exec database mysql --version

 

Leave a Reply

Your email address will not be published. Required fields are marked *