Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker (stopped) container has no IP address

CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS                     PORTS                    NAMES
ca030d3cf1c2        konakart_app                 "/bin/sh -c '/bin/bas"   16 minutes ago      Exited (1) 5 minutes ago                            konakart_app
08909245064b        beantoast/dtkonakart_mysql   "/entrypoint.sh mysql"   54 minutes ago      Up 54 minutes              0.0.0.0:3300->3306/tcp   konakart_db

I'm trying to run konakart app and it's database in two different containers. The database seems to be working fine, but the application itself seems to have no IP. When I type in docker inspect ca03 I get the following:

            "EndpointID": "",
        "Gateway": "",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "IPAddress": "",
        "IPPrefixLen": 0,
        "IPv6Gateway": "",
        "MacAddress": "",

Any idea of how to assign a my IP address, port 8080 to the konakart_app?

like image 650
Miguel Xoel Garcia Avatar asked Nov 03 '16 13:11

Miguel Xoel Garcia


1 Answers

The reason is simple based on the output of docker ps -a result that you posted in the top.

You might have noticed that it is showing status Exited (1) 5 minutes ago for the container whose id is ca030d3cf1c2. That means, container is stopped.

Once container is stopped, it will not have any IPAddress. That's the reason being shown empty in the result of docker inspect ca03 which you posted.

Start the container, you would get the IPAddress.

To your last question, you may have that configuration for port forwarding using your docker-compose.yml file. Or you may also do it while running docker run using -p <hostport>:<container port> option.

Hope this is helpful.

like image 107
Rao Avatar answered Nov 04 '22 09:11

Rao