简体   繁体   中英

Unable to start the MySQL docker container on WSL2

I am currently using a docker container to run MySQL on WSL2 and I am facing an issue while running this container. I checked the docker logs and got the following issue -

Docker started and then immediately exited with the code (1) and then I checked the docker logs and it was giving the error as -

[ERROR] 'Setup of socket: '/var/run/mysqld/mysqlx.sock' failed, another process with PID is using UNIX socket file'

[ERROR] Another process with pid is using unix socket file. [ERROR] Unable to setup unix socket lock file. [ERROR] Aborting

How can I resolve this error and start my container again?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM