0

I have two Docker images :

  • a tomcat image, exposing the port 8080
  • a mysql image, exposing the port 3306

I run two containers using these images, linking mysql with tomcat :

docker run -itd -p 3306:3306 --name mysql mysql docker run -itd -p 8080:8080 --link mysql:mysql --name tomcat tomcat 

When I do that, tomcat communication with mysql works fine, and my tomcat and mysql containers are available on the server host, respectively on ports 8080 and 3306.

Now I would like the port 3306 to be closed on the server host and only available for the tomcat container. How can I do that?

1 Answer 1

1

In that case you can simply skip the -p parameter like:

docker run -itd --name mysql mysql docker run -itd -p 8080:8080 --link mysql:mysql --name tomcat tomcat 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.