Search code examples
dockerraspbianraspberry-pi3docker-network

How to connect a Docker container to a local network


I'm running Docker on a Raspberry Pi 3 using Raspbian (Jessie). I want to access my containers from other PCs on the same network. Can someone explain how can I make containers to show under my router list as an independent machine?

Port forwarding is useless because we are using few ports and if we need to add some new function to it, we must commit the container, delete the container, create a new container under the image created and add the new ports to forward.


Solution

  • Maybe you can try docker ps -a to check the container's states and available ports.

    This is the result on my Linux (IP address is 135.251.247.21):

    sdn@sdn-KVM:~$ docker ps -a 
    
    CONTAINER ID   IMAGE                             COMMAND                  CREATED             STATUS      PORTS                                                                       NAMES
    be8c8289fe20   135.249.45.113:9005/onos:1.7.004  "./bin/onos-service"     3 weeks ago         Up 7 hours  0.0.0.0:6633->6633/tcp, 6653/tcp, 0.0.0.0:8101->8101/tcp, 9876/tcp, 0.0.0.0:9191->8181/tcp   onos-docker
    

    I can access this container from a remote machine via SSH: ssh -p 8101 [email protected].

    If you cannot access your container from a remote machine, you can try to access it on your local machine by running docker exec -it xxx bash, where xxx is the container name.