Docker Community Forums

Share and learn in the Docker community.

[ERROR] Can't run any container that binds a port

My docker recently isn’t working because an crazy bug. I’ve tried everything.

No images/containers are working, if they try to bind any port. For instance, the following simple http server:

docker run -it danjellz/http-server

i get the following error (cannot bind port):

net.js:1420
      throw new ERR_SOCKET_BAD_PORT(options.port);
      ^

RangeError [ERR_SOCKET_BAD_PORT]: Port should be >= 0 and < 65536. Received 65536.

Another example is an mysql server with docker-compose. With the following example:

version: '3'
services:
    db:
      image: mysql:5.7
      command: --log_error_verbosity=1
      environment: # DB configs
        MYSQL_ROOT_PASSWORD: root
        MYSQL_DATABASE: wordpress
        MYSQL_USER: wordpress
        MYSQL_PASSWORD: wordpress

i get the following error:

db_1  | 2020-04-12 23:05:12+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.29-1debian10 started.
db_1  | 2020-04-12 23:05:12+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1  | 2020-04-12 23:05:12+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.29-1debian10 started.
db_1  | 2020-04-12T23:05:13.329093Z 0 [ERROR] Failed to create a socket for IPv4 '0.0.0.0': errno: 13.
db_1  | 2020-04-12T23:05:13.329130Z 0 [ERROR] Can't create IP socket: Permission denied
db_1  | 2020-04-12T23:05:13.329135Z 0 [ERROR] Aborting
db_1  | 
base_db_1 exited with code 1

this happens with all images, i don’t know why. Note that isn’t an error exposing the port

I’ve tried to remove docker completly (according to documentation) and reinstall it. Removed possible packages that may cause network issues, but nothing.

UPDATE

I’ve tried to run an simple ubuntu image: docker run -it ubuntu bash and run an apt update and got the following:

root@2edcf497f8fc:/# apt update
Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease
  Could not resolve 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
  Could not resolve 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
  Could not resolve 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
  Could not resolve 'archive.ubuntu.com'
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Could not resolve 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

# DNS:
root@f2f1a646329c:/# cat /etc/resolv.conf 
# Generated by NetworkManager

nameserver 8.8.8.8
nameserver 8.8.4.4

System info:

              ............                maxjf1@DELL-NOTE-MAX
          .';;;;;.       .,;,.            OS: Deepin 15.11 stable
       .,;;;;;;;.       ';;;;;;;.         Kernel: x86_64 Linux 4.15.0-30deepin-generic
     .;::::::::'     .,::;;,''''',.       Uptime: 42m
    ,'.::::::::    .;;'.          ';      Packages: 2426
   ;'  'cccccc,   ,' :: '..        .:     Shell: zsh 5.3.1
  ,,    :ccccc.  ;: .c, '' :.       ,;    Resolution: 1920x1080
 .l.     cllll' ., .lc  :; .l'       l.   WM: KWin
 .c       :lllc  ;cl:  .l' .ll.      :'   GTK Theme: Mojave-dark [GTK2/3]
 .l        'looc. .   ,o:  'oo'      c,   Icon Theme: Mojave-CT-Night-Mode
 .o.         .:ool::coc'  .ooo'      o.   CPU: Intel Core i5-8300H CPU @ 4GHz
  ::            .....   .;dddo      ;c    GPU: Mesa DRI Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2) 
   l:...            .';lddddo.     ,o     RAM: 3356MiB / 7836MiB
    lxxxxxdoolllodxxxxxxxxxc      :l     
     ,dxxxxxxxxxxxxxxxxxxl.     'o,      
       ,dkkkkkkkkkkkkko;.    .;o;        
         .;okkkkkdl;.    .,cl:.          
             .,:cccccccc:,.  

And if you try mapping ports with -p flag or ports: in docker-compose?

Yeah it does look like some managed containers(the containers created as part of a service) are not getting cleaned up.

Also you cannot remove the docker_gwbridge network if you entered swarm mode because an automatic network attachment happens for ingress traffic which creates an endpoint in docker_gwbridge

And if you try mapping ports with -p flag or ports: in docker-compose?

Check again, i am not even exposing any ports on the compose, i’m just trying to run the container, but if i expose it the result is the same. and this doesn’t happen only with composer, it happens with every way of running an image/container

Yeah it does look like some managed containers(the containers created as part of a service) are not getting cleaned up

as i said, i’ve tried to completly remove docker (following the documentation) and all its files and reinstalled it. The result is the same as before.

Also you cannot remove the docker_gwbridge network if you entered swarm mode because an automatic network attachment happens for ingress traffic which creates an endpoint in docker_gwbridge

I didn’t remove anything manually, just fresh install docker (restarted the pc), and run those examples.

I’ve added more details to the issue