0

I am currently thinking of building a docker image for my ipython parallel nodes. Because its a pain to configure each manually with commands. Will i be able to access this image (located on a different PC on my LAN) simply by typing ssh user@ip on my laptop (Master Node)? How do i get the ip of the docker image running on my Node?

tgogos
  • 23,218
  • 20
  • 96
  • 128
George Pamfilis
  • 1,397
  • 2
  • 19
  • 37
  • This is partly a duplicate of [this question](https://stackoverflow.com/questions/30172605/how-to-get-into-a-docker-container), but you're actually asking at least two, possibly three different things here. – larsks Feb 26 '18 at 13:18
  • Replace the word "docker container" with "isolated application" to understand why this question is going against the grain. It's possible to do things like run an sshd server in a container namespace, but if your app isn't an sshd server, this is probably a bad idea. – BMitch Feb 26 '18 at 14:32

1 Answers1

2

Will i be able to access this image (located on a different PC on my LAN) simply by typing ssh user@ip on my laptop (Master Node)?

You cannot ssh into a container unless you arrange to run sshd inside that container. Normally that's not necessary; as this answer explains you can simply use docker exec to access a running container.

How do i get the ip of the docker image running on my Node?

First, a note about nomenclature: an image is just a collection of files. A container is what you get when you start services from an image. In other words, it doesn't make sense to ask questions about accessing or getting the ip address of an image.

You can get the ip address of a container using the docker container inspect command, which will show you a variety of information about your container. However, this may not be what you want: the ip address of the container will be a private ip address on a docker internal network that is only accessible from the host where you're running docker.

You provide remote access to services by using port forwarding (the -p flag to docker run). For example, if you're running a webserver on port 8080 inside a container, you could make that available on port 80 on your host doing something like:

docker run -p 80:8080 mywebserver

This document describes in more detail some of the options related to port forwarding.

larsks
  • 277,717
  • 41
  • 399
  • 399