all
Currently, I have written a service in the docker container.
Currently, when I exit from my container my service is not running which is expected but when I see
"sudo docker exec -it ps -ef" it shows that MySQL which is installed in my container is up and running if I want the same kind of behavior to my service then what should I do?
Thanks in advance.
You want to run your container detached* with
docker run -d <image_name>
Thanks
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 doing a class project, I have to follow some steps and there's one that is not working. Here's the problem.
I have to use:
docker-compose exec workspace bash
To open a directory and be able to write there:
/var/www$ composer install
In Docker everything seems to be okay installed and configured.
The problem is that docker-compose exec workspace bash is not working. I wrote that in the console and nothing happens or opens VISUALLY. Image below:
But internally, there is something that executes, because when I try to close the window of the console this appears "Processes are running in session":
What's wrong? ¿How can I open docker-componse workspace? Thank you in advance.
One way to access a shell inside your workspace container is to directly exec ur composer inside the container with the command docker exec
Try this:
docker ps
Now find the container id of your workspace container
docker exec -it [container_ID] bash
~$ composer install
I have a MySQL instance running on a docker container. I am trying to access the bash terminal by running "docker exec -t myContainerID /bin/bash" for the container so that I can check into my MySQL and see if the setup is correct. Although after accessing the bash terminal, any command I run is irresponsive. Even something as simple as ls. Is there any way to resolve this or know what might be causing the problem? Thanks.
You seem to be missing the -i option, try running: docker exec -ti CONTAINER_ID /bin/bash
And just FYI:
--interactive , -i Keep STDIN open even if not attached
--tty , -t Allocate a pseudo-TTY
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.