I am facing an issue when i want to run a mysql container: I tried with the example command i found on the Docker hub:
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.6.24
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2569c1a8cbd2 mysql:5.6.24 "/entrypoint.sh mysq…" 5 seconds ago Exited (139) 4 seconds ago some-mysql
Shows that the container exited with code 139
And i can't have a single line of logs: the return of the docker logs command is empty...
~ docker logs 2569c1a8cbd2
~
I am using Docker(v19.03.1, build 74b1e89) for Debian(v10.0)
Are you running other containers? (maybe a separate project?)
I have two separate projects with their separate docker-compose files and their own services.
When one is running, the one with a mysql/mariadb container exits with 139. If I docker-compose down the other project, then the mysql container starts correctly.
I'm still figuring out why (came here for an answer to my problem), but you might have something similar.
Today I had the same issue after an upgrade from Debian 9 to 11. The mysql:5.6.24 Docker image just doesn't want to start. My solution was to upgrade to image mysql:5-debian
https://hub.docker.com/layers/mysql/library/mysql/5-debian/images/sha256-5adbbb05d43e67a7ed5f4856d3831b22ece5178d23c565b31cef61f92e3467ea?context=explore
Related
I'm just using docker for first time and I copy it on the internet
This is my file
Dockerfile
FROM mysql:oracle
COPY dbscript.sql /docker-entrypoint-initdb.d/
and I build it with this command
docker build -t mysqllab
after built I run it
docker run -d --name mysqllabtest -e MYSQL_ROOT_PASSWORD='abc123' mysqllab
it's run and get the message of container id, so I run
docker ps
to see what my container is running but it's don't have this container, I try it again with fast docker ps so I see it run for 4 seconds and terminate
What Can I do with this?
I just use
docker logs mysqllabtest
for check something wrong it about MySQL script so after I edited it It's works! thanks #Hans Kilian for tell me this command
I'm using docker to run a mysql 5.6 instance on my localhost (which is running ubuntu 20.04), using these instructions. When I create a new container for the database I use the following command
sudo docker run --name mysql-56-container -p 127.0.0.1:3310:3306 -e MYSQL_ROOT_PASSWORD=rootpassword -d mysql:5.6
That serves the intended purpose; I'm able to create the database using port 3310 and get on with what I want to do.
However when I reboot my localhost, I am unable to get back into sql5.6 using that port again.
When I list containers, I see none listed:
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
So I try to recreate it and am told that it already exists:
$ sudo docker run --name mysql-56-container -p 127.0.0.1:3310:3306 -e MYSQL_ROOT_PASSWORD=rootpassword -d mysql:5.6
docker: Error response from daemon: Conflict. The container name "/mysql-56-container" is already in use by container "a05582bff8fc02da37929d2fa2bba2e13c3b9eb488fa03fcffb09348dffd858f". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
So I try starting it but with no luck:
$ sudo docker start my-56-container
Error response from daemon: No such container: my-56-container
Error: failed to start containers: my-56-container
I clearly am not understanding how this works so my question is, how do I resume work on databases I've created in a docker container after I reboot?
docker ps just list running containers. If you reboot your laptop, all of them will be stopped. You can use docker ps --all or docker container ls --all to list all containers (running or stopped). You can check more about the docker ps command in docker ps command line reference
Once a container is created, you cannot create another with the same name. Tha is the reason your second docker run is failing.
You should use docker start instead. But you are trying to start a container with a different name. Your docker start command is using a container named my-56-container but it is called mysql-56-container. Please check your first docker run command in the question.
I use mysql image that start with this command
docker run --name test-mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d -p 3306:3306 mysql
when docker run in background, It takes about a minute for another application can connect to port 3306.
After that I stop this container with docker stop test-mysql and then start it with docker start test-mysql. in the second case, with start command, the application can connect to port 3306, just after 5 seconds.
Now I take a snapshot from stopped container with docker commit test-mysql mysql2, and run it with docker run -d mysql2 but in this case, the application can connect to mysql2 after a minute!
So,
What's happen with stopped container, that can be start and responsible just in 5 seconds but mysql image can not do it?
Is there any way to take a snapshot after run container, that can be responsible in 10 seconds?
NOTE: Mysql image has an entrypoint that it takes above a minute to start.
Take a look here: https://stackoverflow.com/a/34783353/7719775 for the first Answer.
And for the second, you should take a look here https://docs.docker.com/engine/reference/commandline/commit/, but even in this case docker start will be faster than docker run command
Start learning docker and try to setup a mysql container. But it dies immediately with Exited(1).
Following is the command used
docker run mysql -e MYSQL_ROOT_PASSWORD=password1
Looking at docker ps, it does not show any running docker container
with docker ps -a returns the following :
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e681f56c52e2 mysql "/entrypoint.sh -e MY" 3 seconds ago Exited(1) 3 seconds ago lonely_rosalind
Nothing shows up for docker logs lonley_rosalind either
Any idea how to determine why if failed ?
I am running
ubuntu 15.04
docker version 1.9.1 build a34a1d5
Try this
docker run -e MYSQL_ROOT_PASSWORD=password1 mysql
When you are writing something after docker image name docker accepts it as a command for execution in your created container. Pattern for docker run:
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
I want to run a mysql container in Docker. The Dockerfile that I use is the Dockerfile defined in the official repo[here].
I only extended this Dockerfile with 2 more lines so I can import a init sql file, like this :
ADD my-init-file.sql /my-init-file.sql
CMD ["mysqld", "--init-file=/my-init-file.sql"]
I want to run this instance as a daemon but when I execute this command, from the documentation:
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=mysecretpassword -d mysql
The container exits automatically. I want to run it as a daemon so I can link apps(like a wordpress site) in another container to the mysql database.
Maybe I am missing something. Can anyone show me how ?
[EDIT] I forgot to say that I ran docker logs my-container after starting the container and there is no error :
Running mysql_install_db ...
Finished mysql_install_db
docker ps shows no running container.
My guess is the command executes successfully but the mysqld daemon does not start.
Your Dockerfile seems fine. Your init file may be buggy, though. If MySQL terminates, then the container will terminate.
The first debug step is to look at the logs:
docker logs some-mysql
You can use this whether the container is stopped or running. Hopefully, you'll see something obvious, like you missed some semicolons.
If the logs don't help, the next thing to try is to get inside the container and see what's happening first-hand
docker run -e MYSQL_ROOT_PASSWORD=mysecretpassword -it mysql /bin/bash
This will get you a Bash shell inside your container. Then you can run
mysqld --init-file=/my-init-file.sql
And see what happens. Maybe something in your init file tells MySQL to exit cleanly, so you get no logs but the command terminates.
Dmitri, after you made docker run with -d argument your container detached and already working as daemon if only CMD command not returned exit code.
You can check running containers by docker ps command.
You can check all containers by running docker ps -a.
Also i think you will need to open mysql port outside the container. You can do it with -P argument or better way to make communication between containers is docker links.