Docker Commands

Docker compose is a tool used for defining and running multi container application. All the configuration stuffs will be written in a YAML[Yet Another Markup Language] file.

Remove all the images:
docker rmi $(docker images -q)

Start the Docker containers:
docker-compose -f <DOCKER_COMPOSE_FILE_NAME> up -d

Stop the Docker containers:
docker-compose -f <DOCKER_COMPOSE_FILE_NAME> stop

Remove the Docker containers:
docker-compose -f <DOCKER_COMPOSE_FILE_NAME> rm

Restart all the Docker containers:
docker-compose -f <DOCKER_COMPOSE_FILE_NAME> restart

Restart a specific service or Docker container:
docker-compose -f <DOCKER_COMPOSE_FILE_NAME> restart <SERVICE NAME>

Stop all containers:
docker stop $(docker ps -a -q)

Remove all containers:
docker rm $(docker ps -a -q)

Command to follow the logs:
docker logs -f <CONTAINER_ID>

Command to follow the logs since from a particular time:
docker logs -f –since=2016-05-10T12:00:00 <CONTAINER_ID>

Remove all the images which has none tag:
docker rmi -f $(docker images | awk ‘{print $1, $3}’ | grep “none” | awk ‘{print $2}’)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s