Reputation: 57
I'm trying to build a sql docker container from ubuntu base. I build the image and run it. And am able to confirm that it's running, however it dies right away. How would I keep it alive?
Docker File
FROM ubuntu
RUN apt-get update && \
apt-get install -y mysql-server
COPY run.sh /sbin/run.sh
COPY createDBTable.sql /
RUN chmod 755 /sbin/run.sh
CMD ["./sbin/run.sh"]
run.sh
#!/bin/sh
service mysql start
cat createDBTable.sql | mysql -u root
echo "show databases" | mysql -u root
Output of docker run
* Starting MySQL database server mysqld
...done.
Database
information_schema
<new table>
mysql
performance_schema
sys
Upvotes: 2
Views: 2633
Reputation: 349
If there is something wrong with the container, you cannot keep it alive. What I would recommend will be to run the following:
docker logs mssql_container_name
replace "mssql_container_name" with the name of the container. If you didn't get the name, type: docker ps -a
and get the name there. If you want you can post the answer to the docker logs here and maybe we can help you. But this is how you find out what happened to a container.
Upvotes: 2
Reputation: 3440
I created a docker container using the dockerfile mentioned above. Instead of running it in background using -d
flag I used -it
to start it in interactive mode. After some time the container stopped with the following error-
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
You can try out various approaches to get rid of the above error using Google.
Upvotes: 1