czwartek, 3 lipca 2014

Docker howto - most useful commands with examples

Docker commands

Most basic commands:

docker pull ubuntu 
- downloads image from Docker repository
docker ps -a
- shows all available containers
docker ps -as
- shows all containers with the actual size of the rw-layer
docker ps -lq
- finds out container id of the last started container

How to remove all containers which name or image matches specified regular expression

  for i in $(docker ps -a | grep "REGEXP_PATTERN" | cut -f1 -d" "); do echo $i; done

Note that this command does not filter containers on any particular field - there is no difference if pattern is found on container name, image name, or any other field.

How to run bash on running container

  docker exec -ti ceb1be03097d /bin/bash

How to create image based on container

  docker commit ceb1be03097d /:

Dockerfile

How to change password to the root user?

RUN echo 'root:my_password' |chpasswd

Troubleshooting

$ docker ps
FATA[0000] Get http:///var/run/docker.sock/v1.16/containers/json: dial unix /var/run/docker.sock: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?

Try the following: $ sudo docker ps

Brak komentarzy:

Prześlij komentarz