MySQL and Wordpress Dockers do not keep running

November 15, 2014 8.3k views

Dear all, I want to get Wordpress running using Docker on CoreOS.
I followed all the instructions for MySQL, I gave the following command:

docker run --name wordpress-mysql -e MYSQL_ROOT_PASSWORD=rtpassword -e MYSQL_USER=fvhemert -e MYSQL_PASSWORD=usrpassword -e MYSQL_DATABASE=wordpress -d mysql

Stangely, the container run for a short while, typing "docker ps" I see it but after some second I "docker ps" again and it is gone, I still see it using "docker ps -a".

Subsequently I give the command:

docker run --name fvhemert-wordpress --link=wordpress-mysql:mysql -e WORDPRESS_DB_USER=fvhemert -e WORDPRESS_DB_PASSWORD=usrpassword -e WORDPRESS_DB_NAME=wordpress -p 8080:80 -d wordpress

There a no further errors but "docker ps" does not show any running containers, they both are present when typing "docker ps -a" and have that status "excited".

I don't want them exited, I though that the "-d" argument would make them runs as daemons and keep them active? There is not active page on the ip.adres:8080 or ip.adres:80.

Any suggestions? What am I doing wrong?

4 Answers

First, check your logs by typing docker logs my-container-name and see what's going on.

I had a similar problem (MySQL on Ubuntu14.04+Docker), and it turned out it was because I was trying to get MySQL up and running on an instance with only 512MB RAM. Since DO's images don't come with a swap file enabled by default, MySQL was filling up the RAM and then – having nowhere to page memory when it fills up – failing.

The two easiest ways to fix this are:

  1. Spin up an instance with at least 1GB of RAM.
  2. Add a swap file to your instance.

Hope this helps.

by Jai Boudreau
This article will cover the pros and cons of using virtual memory or a swap file (paging), determining if your droplet already uses virtual memory or paging, the differences between a swap partition and a swap file, information on how to create a swap file, and how to configure the system's "swappiness" (how likely it is to use virtual memory as well as determining the appropriate size to use).
  • I don't think that is it. I have more 512 instances with MySQL and several Drupal websites and no problems. But when I spin up the mysql image:

    docker run -t -i mysql:latest /bin/bash

    All mysql commands end in:
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    I guess I'm going to report on the image webite:

  • The MySQL container works fine to me.
    The problem is from the wordpress:latest dockerfile, I cannot start it via "sudo docker run --name xxwordpress --link xx-mysql:mysql -p 3825:80 -d wordpress", and I cannot see the wordpress docker logs via "docker logs <container id>".

I'm having the same problems. How did you guys solve this?


Your original mysql docker command is as follows:

docker run --name wordpress-mysql -e MYSQLROOTPASSWORD=rtpassword -e MYSQLUSER=fvhemert -e MYSQLPASSWORD=usrpassword -e MYSQL_DATABASE=wordpress -d mysql

"Looking" at this i think you are missing the -p command that specifies a port for mysql operations aka tcp:3306.

There are two ways you can sort this out.

  1. use --expose 3306 when running mysql container.

  2. use -p :3306:3306 when running mysql container. (just make sure you don't allow wan access on 3306).

Hopefully, this should solve your problem.

Best Regards
Hareem Haque

If you have $5 512M Droplet, just enable swap.
I stuck with this for a few days until I found this solution.

by Etel Sverdlov
Linux swaps allow a system to harness more memory than was originally physically available. Here's how to set up a linux swap file on Ubuntu 12.04
Have another answer? Share your knowledge.