I’m attempting to set up a MySql container as part of a continuous deployment pipeline. My Dockerfile only contains the following:
From mysql/mysql-server:8.0
I also have the following script:
docker build -t mysql_database .
docker stop mysql_database
docker rm mysql_database
docker run -d --name mysql_database -v mysql_data:/var/lib/mysql mysql_database
docker ps
which outputs:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d131d4149481 mysql_database "/entrypoint.sh mysq…" Less than a second ago Up Less than a second (health: starting) 3306/tcp, 33060-33061/tcp mysql_database
If I do ‘docker ps’ a moment later, then the output is empty.
However, if I now come back to the terminal and type
docker run mysql_database
There is a very long output, the gist of which seems to be the container starting up and setting up mysql the first time
if I now do ‘docker ps’, the output is:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
25680ab3c183 mysql_database "/entrypoint.sh mysq…" 59 seconds ago Up 58 seconds (healthy) 3306/tcp, 33060-33061/tcp kind_torvalds
and if I repeat it a moment later, the output is the same, and I can log into mysql via port 3306.
What gives here? If you can’t tell, my aim is to use the docker volume to store the data but be able to update the database container in an automated fashion. Right now it seems like it can only work if I come along and type in ‘docker run’ myself each time.
Base OS: Ubuntu 22.04.4
Docker 27.0.3
MySql 8.0
Any help or suggestions are appreciated, thank you