| Home | Techniek | Docker | Server | Linux | Git | Wildfly | Promgrammeer

Docker

Table 1. Docker
Command Description

docker version

Does Docker work?!

docker run learn/tutorial echo "hello world"

Run the command echo "hello world" in tutorial.

docker run learn/tutorial ps -l

Check out the processes in the container.

docker run -t -i ubuntu /bin/bash

Start a shell in the ubuntu container.

docker exec -ti {HASH} /bin/bash

Connect to a running container.

docker run –d {imagename}

Run container in background

docker build -t {imagename} .

Build a new image from the Dockerfile in the current directory.

docker images

List all your local images.

docker ps

List all your running containers.

docker ps -a

List all your containers.

docker inspect {HASH}

Show the properties of a docker container

docker stop {HASH}

Stop a docker container

docker exec -ti {HASH} {COMMAND}

Start an interactive session with a container and start a command (i.e. bash)

docker rmi {HASH}

Remove an image.

docker rm {HASH|NAME}

Remove a container.

docker rm $(docker ps -aq)

Remove all containers.

Table 2. Docker-compose
Command Description

docker-compose up –d

Start multiple containers defined in de docker-compose.yml file

docker-compose stop

Stop multiple containers defined in de docker-compose.yml file

docker-compose rm

Remove multiple containers defined in de docker-compose.yml file

Table 3. Docker Machine
Command Description

docker-machine ls

Show the virtualboxes, also with the URL’s

docker-machine env

Show the environment variables, can be used to set the environment vars (see last line)

Docker-machine ssh

Log in to the virtual box where docker runs with a ssh connection.

Advanced

Get the shell on the current running docker:

docker exec -ti `docker ps -q` /bin/bash`

Error

Error with "No such image:" in docker-compose. An old cache issue.

docker-compose rm will probably solve the error.

Certificate signed by unknown authority

In Linux:

  • Create a folder /etc/docker/certs.d

  • In that folder: servername.com:portnumber

  • Create a file ca.crt with the certificate of that server.