Docker errors

Introduction

In this article you can find the errors I have met Docker

You can read the instructions on working with Docker here and here

Bind for 0.0.0.0:80 failed: port is already allocated.

docker: Error response from daemon: driver failed programming external connectivity on endpoint web (8b4ccb280aa958668c714013462f1a84334118d41bbd5505e7bfdc23331c2ce5): Bind for 0.0.0.0:80 failed: port is already allocated.

You most likely already have a container running that is listening

Run

docker ps -a

Look at which of the Up containers is using the port

Stop it with the command

docker stop container_name

Note that the container name may not match You need the NAMES column

the input device is not a TTY

the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'

You are most likely trying to start, for example, ubuntu in docker under Windows . For example

docker exec -it myubuntu bash

Try to follow the advice and run

winpty docker exec -it myubuntu bash

ls: cannot access

ls: cannot access 'C:/Program Files/Git/': No such file or directory

You most likely have, for example, ubuntu running in docker and Windows and you are trying to run some command inside the container or Try running without /

docker exec myubuntu ls /

or

docker exec myubuntu cat /data.txt

Try running without /

docker exec myubuntu ls

or

docker exec myubuntu cat data.txt

Got permission denied

docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/create: dial unix /var/run/docker.sock: connect: permission denied. See 'docker run --help'.

Perhaps the user who runs docker run does not

You can check whether the docker group exists with the command

groups

andrei adm cdrom sudo dip plugdev lpadmin lxd sambashare docker

If the docker group already exists, go to the next step If it does not exist, create it with the command

sudo groupadd docker

You have to add the user to the docker group with the command

sudo usermod -aG docker username

Now you only have to log in again and everything should work

If that did not help, run additionally

newgrp docker

You can read more about administering users and groups in Linux in the article «Users in Linux»

unable to prepare context: context must be a directory

unable to prepare context: context must be a directory: /home/andrei/docker/Dockerfile

Usually this error appears when someone unsuccessfully tries to explicitly Dockerfile you have to use it for building the container.

An example of the correct way to specify the Dockerfile with the option

docker build -t andrei-debian:1.0 -f Dockerfile-debian .

You can read the details about building containers in the article docker build

debconf: unable to initialize frontend: Dialog debconf: (TERM is not set, so the dialog frontend is not usable.) debconf: falling back to frontend: Readline debconf: unable to initialize frontend: Readline debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7, <> line 18.) debconf: falling back to frontend: Teletype dpkg-preconfigure: unable to re-open stdin:

Configuring tzdata ------------------ Please select the geographic area in which you live. Subsequent configuration questions will narrow this down by presenting a list of cities, representing the time zones in which they are located. 1. Africa 6. Asia 11. System V timezones 2. America 7. Atlantic Ocean 12. US 3. Antarctica 8. Europe 13. None of the above 4. Australia 9. Indian Ocean 5. Arctic Ocean 10. Pacific Ocean Geographic area:

It hangs after the input

docker.io : Depends: containerd

When trying to install Docker on Ubuntu

sudo apt install docker.io

The error appears

Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: docker.io : Depends: containerd (>= 1.2.6-0ubuntu1~) E: Unable to correct problems, you have held broken packages.

You have to update apt and install containerd

sudo apt -y update
sudo apt -y upgrade
sudo apt -y install containerd

Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: runc The following packages will be REMOVED: containerd.io docker-ce The following NEW packages will be installed: containerd runc 0 upgraded, 2 newly installed, 2 to remove and 0 not upgraded. Need to get 36.9 MB of archives. After this operation, 45.6 MB disk space will be freed. Get:1 http://fi.archive.ubuntu.com/ubuntu focal-updates/main amd64 runc amd64 1.1.0-0ubuntu1~20.04.1 [3,892 kB] Get:2 http://fi.archive.ubuntu.com/ubuntu focal-updates/main amd64 containerd amd64 1.5.9-0ubuntu1~20.04.4 [33.0 MB] Fetched 36.9 MB in 5s (7,316 kB/s) (Reading database ... 254483 files and directories currently installed.) Removing docker-ce (5:20.10.18~3-0~ubuntu-focal) ... Warning: Stopping docker.service, but it can still be activated by: docker.socket Removing containerd.io (1.6.8-1) ... Selecting previously unselected package runc. (Reading database ... 254461 files and directories currently installed.) Preparing to unpack .../runc_1.1.0-0ubuntu1~20.04.1_amd64.deb ... Unpacking runc (1.1.0-0ubuntu1~20.04.1) ... Selecting previously unselected package containerd. Preparing to unpack .../containerd_1.5.9-0ubuntu1~20.04.4_amd64.deb ... Unpacking containerd (1.5.9-0ubuntu1~20.04.4) ... Setting up runc (1.1.0-0ubuntu1~20.04.1) ... Setting up containerd (1.5.9-0ubuntu1~20.04.4) ... Processing triggers for man-db (2.9.1-1) ...

Article author: Andrei Olegovich