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


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 comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.