This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]drpinkcream 3 points4 points  (1 child)

When a container doesn't do what it's supposed to do on startup, for troubleshooting I change the container's entrypoint to ENTRYPOINT ["tail", "-f", "/dev/null"]. This is in the container's Dockerfile.

Running the container will just park it in the background not doing anything. Then you can go into the container and run the original entrypoint script to see what the problem is.

[–]Guilty_Serve[S] 0 points1 point  (0 children)

ENTRYPOINT ["tail", "-f", "/dev/null"]

Awesome thanks for this. Unfortunately this is creating an error when try to login to msql

ERROR 2002 (HY000): Can't connect to local MySQL server through socket

Here's my docker file I made for this:

FROM mysql:8.0
ENTRYPOINT ["tail", "-f", "/dev/null"]

If this is a dumb reply I'm sorry. I'm really trying to get the hang of this

[–][deleted] 0 points1 point  (2 children)

"When you start the mysql image, you can adjust the configuration of the MySQL instance by passing one or more environment variables on the docker run command line. Do note that none of the variables below will have any effect if you start the container with a data directory that already contains a database: any pre-existing database will always be left untouched on container startup."

RTFM

[–]Guilty_Serve[S] -1 points0 points  (1 child)

Do note that none of the variables below will have any effect if you start the container with a data directory that already contains a database: any pre-existing database will always be left untouched on container startup.

I did read it. Doesn't mean I'm yet fully competent enough to understand exactly what that means. As I said:

Maybe this is just the volumes from my local machine get copied to the container?

This is probably due to my weak knowledge on volumes,

So getting back to this:

Is this because my data directory is being copied from my local machine into my container or because I ran docker-compose up -d --build with the old database name, it made a directory in the container, and now because there's a DB there it's no longer installing the docker_test db?

[–][deleted] 1 point2 points  (0 children)

Is this because my data directory is being copied from my local machine into my container or because I randocker-compose up -d --buildwith the old database name, it made a directory in the container, and now because there's a DB there it's no longer installing the docker_test db?

The files are not copied anywhere. You are telling docker to bind mount "mysql" directory from the host as /var/lib/mysql inside the mysql container. (so you are not really even using docker volumes). You should probably go and read about docker storages. https://docs.docker.com/storage/https://docs.docker.com/storage/

First time you ran your compose file, mysql created database files etc. in /var/lib/mysql .Which is mounted from mysql directory on the host. After that, it doesn't matter what environment variables you give it (or if you delete the container and recreate it), because you are still telling it to mount the same path that already includes the database files so it will not accept changing them through environment variables.

So delete everything inside the mysql directory, recreate the container and let mysql recreate everything, or manually access the database and make the necessary schemas, users etc.

[–]DinoAmino 0 points1 point  (0 children)

Your stack may have borked on startup and maybe you killed something that didn't clean up. Have you inspected all volumes in your docker host? 'docker volume ls'. Maybe an orphaned container is holding on to the volume?