How to link one running container with other running container in docker.

+1 vote
Docker
Dec 13, 2019 in Docker by Abhinitk
• 130 points
150 views
Hi, I need something similar. I have a database server running on one of the containers and I have another container that fetches the data from the first container. So I need the two containers to be linked and connected.

Is this possible?
@Abhishek have a look at my answer. I am not very sure about your requirement. If this answer does not help, please give a detailed explanation of your requirements.

@Yuvraj, I hope your doubt is cleared.

Thank you!

1 answer to this question.

0 votes

Hi @Yuvraj! Yes, this is possible.

You can sue the link flag for this.
When you launch the second container, use a command similar to this:

$ docker run -it --link redis1:redis --name redisclient1 busybox

The value provided to the — link flag is sourcecontainername:containeraliasname. We have chosen the value redis1 in the sourcecontainername

The above launch of the container (redisclient1) will lead you to the shell prompt.

answered Dec 16, 2019 by Kalgi
• 51,850 points

Related Questions In Docker

0 votes
1 answer

How to store data in external drive with Docker Postgres:9.3 image?

Apparently, the problem would be in your ...READ MORE

answered Jul 12, 2018 in Docker by Kalgi
• 2,620 points
489 views
0 votes
1 answer

How to deal with persistent storage (e.g. databases) in docker

For Docker 1.9.0 and above, Use volume API docker ...READ MORE

answered Jul 18, 2018 in Docker by Kalgi
• 2,620 points
114 views
0 votes
1 answer

How to continue running a docker container which is already exited?

Restart an existing container after you exited ...READ MORE

answered Jul 19, 2018 in Docker by Sophie may
• 9,940 points
620 views
0 votes
1 answer

How to base a docker volume with docker container?

Run the following command: docker run -d --volumes-from ...READ MORE

answered Aug 5, 2018 in Docker by Sophie may
• 9,940 points
189 views
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 57,530 points
538 views
0 votes
1 answer

How to create a container and run images in docker?

Look for what all images you have ...READ MORE

answered Feb 22, 2019 in Docker by Kalgi
• 51,850 points
223 views
+4 votes
4 answers

How To Access a Service on Host From a Docker Container?

Adding to kalgi's answer, You can also ...READ MORE

answered Oct 16, 2018 in Docker by lina
• 8,200 points

edited Oct 16, 2018 by lina 11,653 views