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

+2 votes
Docker
Dec 14, 2019 in Docker by Abhinitk
• 140 points
1,715 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
• 52,360 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,680 points
2,332 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,680 points
576 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
• 10,610 points
2,258 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
• 10,610 points
879 views
+2 votes
1 answer
+2 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
• 58,090 points
2,435 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 23, 2019 in Docker by Kalgi
• 52,360 points
1,815 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,220 points

edited Oct 16, 2018 by lina 32,899 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP