0

I have got a problem with launching MySQL container.

I run MySQL container with below command:

$ sudo docker run -d –name stockdb -e MYSQL_ROOT_PASSWORD=yang1234 -e MYSQL_DATABASE=stkanalysis mysql:5.7 -p 3307:3306

and checked result using

$ sudo docker ps -a

This is the result.

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
34e98ad90f73 mysql:5.7 “docker-entrypoint…” 2 seconds ago Exited (1) 1 second ago stockdb

When I launched same MySQL container without option -p, it worked well like this:

$ sudo docker run -d –name stockdb -e MYSQL_ROOT_PASSWORD=yang1234 -e MYSQL_DATABASE=stkanalysis mysql:5.7

But, whenever I put the port forwarding option -p, running container is failed(technically, it is exited as soon as runed)

I hope to run MySQL container with port forwarding to connect its DBMS from outside host.

I’m using Ubuntu 16.04 and Docker version is 17.09.0-ce.