Docker commands in practice

Diese Seite gibt es auch in Deutsch

Docker containers can be started, updated and managed using terminal commands. In the post I note commands that I have needed so far for Docker and corresponding examples:

Create network

docker network create smart-home

A network can combine several containers that are to communicate with each other.

Start container

as an example Conbee

 docker run -d \
   --name=deconz \
   --network=smart-home \
   -p=83:80 \
   --restart=always \
   -v /etc/localtime:/etc/localtime:ro \
   -v /docker/deCONZ/:/root/.local/share/dresden-elektronik/deCONZ \
   --device=/dev/ttyACM0 \
   -e DECONZ_DEVICE=/dev/ttyACM0 \


Folders of the host operating system can be mapped into the container with the -v parameter:

   -v /docker/deCONZ/:/root/.local/share/dresden-elektronik/deCONZ

":ro" at the end maps the folder read only

   -v /ReadOnlyFolder/:/ReadOnlyFolder:ro

Container parameters: Network

The parameter: --net=host connects the network card directly.

Alternatively, the parameter

-p=external_port,port_in_container can be used:

-p=83:80 would therefore then be accessible via the IP of the computer using port 83 and internally in the container port 80 is used.

Additionally, a specific network previously created with "docker network create" can be used with --network=network-name. Containers within a network can be called not only by IP, but also by their name (--name): The name and port of the container is then simply used to establish the connection..

Show container

user@rechner:/docker$ docker ps
CONTAINER ID        IMAGE                                    COMMAND                  CREATED             STATUS                    PORTS                                      NAMES
xxxxxxxxxxxx        syncthing/syncthing:latest               "/bin/ …"   12 minutes ago      Up 12 minutes (healthy)                                              festive_chandrasekhar
xxxxxxxxxxxx        nginx                                    "/docker-entrypoint.…"   4 days ago          Up 12 minutes             80/tcp                                     nextcloud_webserver
xxxxxxxxxxxx        nextcloud:fpm                            "/ php-…"   4 days ago          Up 12 minutes             9000/tcp                                   nextcloud_fpm
xxxxxxxxxxxx        nginx                                    "/docker-entrypoint.…"   4 days ago          Up 12 minutes             80/tcp                                     laraveldev_webserver
xxxxxxxxxxxx        mediawiki                                "docker-php-entrypoi…"   4 days ago          Up 12 minutes             80/tcp                                     mediawiki
xxxxxxxxxxxx        laravelapp.dockerfile                    "docker-php-entrypoi…"   4 days ago          Up 12 minutes             9000/tcp                                   laravelapp
xxxxxxxxxxxx        phpmyadmin/phpmyadmin                    "/docker-entrypoint.…"   4 days ago          Up 12 minutes   >80/tcp                       phpmyadmin
xxxxxxxxxxxx        onlyoffice/documentserver                "/bin/sh -c /app/ds/…"   4 days ago          Up 12 minutes             80/tcp, 443/tcp                            onlyoffice
xxxxxxxxxxxx        jrcs/letsencrypt-nginx-proxy-companion   "/bin/bash /app/entr…"   4 days ago          Up 12 minutes                                                        letsencrypt-companion
xxxxxxxxxxxx        mariadb                                  "docker-entrypoint.s…"   4 days ago          Up 12 minutes             3306/tcp                                   mediawikidb
xxxxxxxxxxxx        jwilder/nginx-proxy:alpine               "/app/docker-entrypo…"   4 days ago          Up 12 minutes   >80/tcp,>443/tcp   proxy
xxxxxxxxxxxx        mariadb                                  "docker-entrypoint.s…"   4 days ago          Up 12 minutes             3306/tcp                                   db
xxxxxxxxxxxx        mariadb                                  "docker-entrypoint.s…"   4 days ago          Up 12 minutes             3306/tcp                                   laraveldb
xxxxxxxxxxxx        redis                                    "redis-server --appe…"   4 days ago          Up 12 minutes   >6379/tcp                     redis
xxxxxxxxxxxx        laradock_nginx                           "/bin/bash /opt/star…"   3 months ago        Up 11 minutes   >80/tcp,>443/tcp   laradock_nginx_1
xxxxxxxxxxxx        laradock_php-fpm                         "docker-php-entrypoi…"   3 months ago        Up 11 minutes             9000/tcp                                   laradock_php-fpm_1
xxxxxxxxxxxx        laradock_phpmyadmin                      "/ supervisord…"   3 months ago        Up 12 minutes             9000/tcp,>80/tcp             laradock_phpmyadmin_1
xxxxxxxxxxxx        laradock_workspace                       "/sbin/my_init"          3 months ago        Up 12 minutes   >22/tcp                       laradock_workspace_1
xxxxxxxxxxxx        laradock_mariadb                         "docker-entrypoint.s…"   3 months ago        Up 12 minutes   >3306/tcp                     laradock_mariadb_1
xxxxxxxxxxxx        laradock_redis                           "docker-entrypoint.s…"   3 months ago        Up 12 minutes   >6379/tcp                     laradock_redis_1

Stop container

docker stop containername

stop all containers

docker stop $(docker ps -a -q)

Update container

docker pull IMAGENAME
docker run CONTAINERNAME -parameters

Update Docker Compose Container

docker-compose pull
docker-compose up -d

Remove container

docker rm containername

Show network

user@rechner:/docker$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
xxxxxxxxxxxx        docker_default      bridge              local
xxxxxxxxxxxx        host                host                local
xxxxxxxxxxxx        laradock_backend    bridge              local
xxxxxxxxxxxx        laradock_default    bridge              local
xxxxxxxxxxxx        laradock_frontend   bridge              local
xxxxxxxxxxxx        nginx-proxy         bridge              local
xxxxxxxxxxxx        none                null                local

Show detail of a network

docker network inspect docker_default

Calling the bash of a container

docker exec -it containername /bin/bash

Bash commands inside: mysql, mariadb DB restore

gunzip < '/daten/backup.gz' | docker exec -i laradock_mariadb_1 /usr/bin/mysql -u root --password=password dbname


Remove unneeded Docker images

docker image prune -a --force

Prune: delete unused data

docker system prune --volumes -f 

Monitor / Status


An overview of CPU / RAM and network is provided by the command docker stats

docker stats

Show output of each container

docker logs -f containername


Docker stops responding

for example, if commands like docker ps stop responding, the error can be narrowed down using the dockerd --debug command:

sudo dockerd --debug
INFO[2020-12-27T11:58:52.395359797+01:00] Starting up                                  
failed to start daemon: pid file found, ensure docker is not running or delete /var/run/

The file can be deleted with the following command:

sudo rm /var/run/

failed to start daemon: error while opening volume store metadata database: timeout

I was able to fix Docker again using the following commands:

Stop all Docker processes:

ps axf | grep docker | grep -v grep | awk '{print "kill -9 " $1}' | sudo sh

Delete Metadata.db

sudo rm /var/lib/docker/volumes/metadata.db

Display the status

systemctl status docker

Reinstall Docker

sudo apt-get remove docker-ce
sudo apt-get install docker-ce
positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Top articles in this section

Preview Running Docker Mailserver yourself | a field report

Running Docker Mailserver yourself | a field report

created: 04.05.2022 from Bernhard

With the help of a suitable Docker image, it is relatively easy to run a mail server yourself. I originally used the integrated mail server of the Hosteurope vServer (Plesk) and came across a very simple Docker container while looking for a replacement. The lightweight container provides a mail server without a graphical management interface, but can be managed with a few simple commands. Any email client can be used to send and receive the mails, for this POP3 or IMAP is offered for receiving a... ... continue reading

Home Assistant Docker Conbee 2 and Zigbee2MQTT / deCONZ

Home Assistant Docker Conbee 2 and Zigbee2MQTT / deCONZ

created: 09.05.2022 from Bernhard

Thanks to numerous integration options, Home Assistantis a simple platform for controlling a wide range of smart home devices. Compared to ioBroker, I found it much easier to get started with Home Assistant. While for ioBroker I was still looking for which frontend I could use for my dashboards, with Home-Assistant I had a ready-made system out of the box. Home Assistant's Lovelance dashboards can be easily clicked together in the GUI and adapted almost at will for special customizations in the... ... continue reading

Preview Nextcloud SSL - letsencrypt https | Docker

Nextcloud SSL - letsencrypt https | Docker

created: 05.05.2022 from Bernhard

To synchronize contacts, appointments and photos with my NAS, I tested Nextcloud and thus turned my back on other cloud providers for my private data to some extent. Thanks to Docker, the installation is easier and more flexible than ever, allowing NextCloud to run on almost any hardware. ... continue reading

Questions / Comments

By continuing to browse the site, you agree to our use of cookies. More Details