Docker logo

Some usefull commands in Docker

I started playing with Docker and here I will write some commands that where not so obvious at beginning 🙂

List running containers:

docker ps

List also not running containers:

docker ps -a

Remove all containers (be careful with that):

docker rm $(docker ps -a -q)

Remove all images:

docker rmi $(docker images -q)

Docker won’t remove any old volumes used by containers, so after some time you may be interested in deleting them all:

docker volume rm $(docker volume ls -q)

Run container and enter bash:

docker run --name deb -t -i debian:jessie /bin/bash

Run containter and remove it after exit:

docker run --name deb -t -i --rm debian:jessie /bin/bash

Show build logs from container:

docker logs deb

Enter bash into running container:

docker exec -it deb /bin/bash

Build image from Dockerfile in current directory:

docker build -t my_web .

After playing a little with this command I started searching for something to automate my tasks a little, and found docker-compose – you may be interested in it too.


Leave a Reply

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.