Docker Community Forums

Share and learn in the Docker community.

How to share services between docker


(Jedduff) #1


I’m new at docker. I try to read all about it. But I don’t understand something about linking services between containers.

First this is the setup I’m using :

  • Vmware Workstation 12 on a Windows 10 1709 host machine
  • Docker 17.09.1-ce on a virtual Ubuntu 16.04 server host.
  • Rancher for the containers management

My big question is : How to link the services between containers?

I create a stack on Rancher with these 2 containers :

  • hugojosefson/ubuntu-gnome:17.04 with IP (called it Ubuntu-Home for purpose)
  • rastasheep/ubuntu-sshd:16.04 as sidekick with IP called it Ubuntu-sshd (I know! It’s a pretty wild network range!)

This is the thing I want to do :

  • My Ubuntu-Home don’t have a ssh server on it. So I created a stack of this container + a sshd-server container.

All both of the containers can contact each other because now, they are in the same network


How can I tell my Ubuntu-Home : Hey use openssh-server on the other container in the same network?

I’m a little bit confused about that

(Sam) #2

service is really database or api… and ssh server enables users to connect to a particular container…(all would have to run the server themselves for users to connect to each one)

(Jedduff) #3

So, if I understand, I need to install openssh-server on the Ubuntu-Home, right?

(Sam) #4

correct, so that you can ssh to it… now, why do you want to ssh?

from the docker host where the container is running, you should be able to docker attach container_id to get a commandline…

typically, docker containers run one application.

(Jedduff) #5

Ok thanks.

Well, I want to use ssh and redirect X11 for an application I want to use in my windows computer, this is why i need SSH.

(Jedduff) #6

Ok, I think I get it!

I installed openssh-server on my Ubuntu-Home, did a commit into the name Ubuntu-Homev2 and docker run -p 32000:22 -td Ubuntu-Homev2