4

I'm trying to run a docker mysql container with initialized db according instruction provided in this message https://stackoverflow.com/a/29150538/6086816. After first run it works ok, but on second run, after trying of executing /usr/sbin/mysqld from script, I get this error:

db_1 | 2016-03-19T14:50:14.819377Z 0 [ERROR] Another process with pid 10 is using unix socket file.

db_1 | 2016-03-19T14:50:14.819498Z 0 [ERROR] Unable to setup unix socket lock file.

...

mdir_db_1 exited with code 1

what can be the reason of it?

Community
  • 1
  • 1
Arnold Eden
  • 39
  • 1
  • 5

4 Answers4

2

You should make sure the socket file have been deleted before you start mysql.Check my.cnf(/etc/mysql/my.cnf) file to get the path of socket file. find sth like this socket = /var/run/mysqld/mysqld.sock.And delete the .sock.lock file as well.

1

This is a glitch with docker.

Execute following commands:

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

This will stop all containers and remove them.

After this it should work just fine.

Arghya Sadhu
  • 35,183
  • 9
  • 62
  • 80
1

I was facing the same issue. Following are the steps that I tried to resolve this issue -

  • Firsly, stop your docker service by using following command - "sudo service docker stop"

  • Now,get into the docker folder in my Linux system using the following path - /var/lib/docker.

  • Then within the docker folder you need to get into the volumes folder. This folder contains the volumes of all your containers (memory of each container) - cd /volumes

  • After getting into volumes do 'sudo ls' you will find multiple folders with hash names. These folders are volumes of your containers. Each folder is named after its hash (You need to inspect your docker container and get the hash of your container volume. For this, you need to do the following steps -

Run command "docker inspect 'your container ID' ".

Now you will get a JSON file. It is the config file of your docker container.

Seach for Mounts key within this JSON file. In Mounts, you will get the Name(hash) of your volume. (You will also get the path of your volume within the Mounts. Within Mounts "Name" key is your volume name and "Source" is the path where your volume is located.)).

  • Once you get the name of your volume you can go within your volume folder and within this folder you will find "_data" folder. Get into this folder.

  • Finally within "_data" folder use sudo ls command and you will find a folder with the name mysql.sock.lock. Remove this folder By "rm -f mysql.sock.lock".

  • Now restart your docker service and then start your docker container. It will start working.

Note- Use sudo in each command while you are in the docker container folder.

0

I had the same problem and got rid of it in an easy and mysterious way.

First I have noticed that I am unable to start mysql_container container. Running docker logs mysql_container indicated exactly the same problem as described repeating for few times.

I wanted to get a look around by running the container in an interactive mode by docker start -i mysql_container from one bash window while running things like docker exec -it mysql_container cat /etc/mysql/my.cnf in another.

I have done that and was very surprised to see that this time the container started successfully. I cannot understand why. I can only guess that starting an interactive mode together with running subsequent docker exec commands slowed down init process and some another process had a bit more time to remove its locks.

Hope that helps anybody.

Kuba D
  • 19
  • 4