How to reboot centos in docker ?
I had pulled centos 7 from docker
use the 'shutdown -r now'
The console said 'Failed to talk to init daemon.'
I also used 'reboot -f' , and get the
'Rebooting.
Failed to reboot: Operation not permitted' for rsp
Why you want to restart container?
if it is necessary you can use
docker exec -it <container name> reboot
or you can stop container and start it again
docker stop -f <container name>
then
docker start <container name>
Assuming you are logged in to your container and trying to "reboot" the container:
e.g. docker run -i -t centos /bin/bash
and then reboot
You shouldn't do is.
Please use docker run/start/stop....
Related
Why when i run the command
docker run ubuntu
without option '-it' is not possible to interact with the created container even when running command start with the -a -i options
docker start -a -i CONTAINER_ID
or when i run
docker start CONTAINER_ID
simply the container has the status "Exit (0) 4 seconds ago"
But when i run
docker run -it ubuntu
i can use bash shell of ubuntu using 'docker start -a -i'
When you run docker run without -it it's still running the container but you've not given it a command, so it finishes and exits.
If you try:
docker run ubuntu /bin/bash -c "echo 'hello'";
It'll run ubunu, then the command, and then finish because there is no reason for it to be kept alive afterwards.
-i is saying keep it alive and work within in the terminal (allow it to be interactive), but if you type exit, you're done and the container stops.
-t is showing the terminal of within the docker container (see: What are pseudo terminals (pty/tty)?)
-it allows you to see the terminal in the docker instance and interact with it.
Additionally you can use -d to run it in the background and then get to it afterwards.
Ex:
docker run -it -d --name mydocker ubuntu;
docker exec -it mydocker /bin/bash;
TLDR is -it allows you connect a terminal to interactively connect to the container.
If you run docker run --help, you can find the details about docker run options.
$ docker run --help
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Run a command in a new container
Options:
...
-i, --interactive Keep STDIN open even if not attached
...
-t, --tty Allocate a pseudo-TTY
I have a simple Ubuntu 16.10 container which has docker.io installed.
The docker process terminates after it starts and log has this information. Any troubleshooting suggestions?
$ docker run -it --name dcos-ubuntu-python5 python-docker /bin/bash
root#5ff6bb6b6dc7:/# docker run hello-world
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
root#5ff6bb6b6dc7:/# service docker start
* Starting Docker: docker [ OK ]
root#5ff6bb6b6dc7:/# service docker status
* Docker is not running
root#5ff6bb6b6dc7:/# tail -f /var/log/docker.log
time="2017-12-21T17:09:45.464736873Z" level=info msg="libcontainerd: new containerd process, pid: 50"
time="2017-12-21T17:09:46.472578239Z" level=fatal msg="Error starting daemon: error initializing graphdriver: operation not permitted"
Why do you want to run docker within docker container?
Docker-in-Docker is developed to help docker development. And it needs --privileged flag to run docker container.(Please read jpetazzo's blog here.)
If you really want to execute docker in docker container, you also have other options.
Bind mount docker.sock. Some people call this DooD(Docker-outside-of-Docker)
docker run -v /var/run/docker.sock:/var/run/docker.sock ...
Install docker(client) and specify DOCKER_HOST to access remote docker daemon. Be careful about socket protection with certificates.
Are you running docker as sudo if not run as sudo or
Else add user group to docker
docker group. For this run following command:
sudo usermod -aG docker $USER
The answer was simple.
docker run -it --privileged --name dcos-ubuntu-python5 python-docker /bin/bash
(This was also mentioned partly in #SunghoMoon's response. So Credits to him).
If start a docker container like:
docker run -d -p 5000:5000 --name registry registry:2
It can be seen when run
docker ps
But after restart machine and run docker ps again, it can't been found.
When check docker ps -a can see it exist.
How to week it up at this case if don't want to kill this process to run a new one?
Docker containers don't start automatically on system boot because the Docker default restart policy is set to no.
To achieve that you shoud do:
docker update --restart=always <container ID or name>
I have problem with Docker. I created new container using sudo docker run --name myXampp -p 41061:22 -p 41062:80 -d -v ~/Projekty/Xampp:/www pindr0p/xampp and I could access localhost:41062, but when i restarted my pc, i wanted to run docker container and again access server so I did sudo docker start myXampp but I can not access localhost:41062 anymore. Did I miss something? I even tried start with -p flags, but no success. Please help me.
Thanks
Restart your container by container Id
List all the containers who are existed or check the status of your containers after restart
docker ps -a
Then restart the container by Contaner Id
docker restart <container_id>
try to remove it competently
first please get list of dockers run as process
docker ps
then try to remove it:
docker rm <your-docker> --force
then try to run
docker ps
and make sure the docker removed
then try to
docker run blob
again
yes the container made from image again and all your new config reverted back
Stop the container using:
sudo docker stop 29ddc6836adfa14d4ec3a025fddd2e5587212fef77ba0d6edb83642a3daedd3e
and then try:
sudo docker run --name myXampp -p 41061:22 -p 41062:80 -d -v ~/Projekty/Xampp:/www pindr0p/xampp
If I spin up a Docker container with:
docker run -it ubuntu /bin/bash
and then exit. I can see the container using
docker ps -a
However, if I try and restart the container with
docker start <container ID>
I just get echoed back and returned to the command prompt.
What am I missing?
After running docker start <container ID> to restart the container try running a docker ps to ensure it's actually running.
If it IS running and you want to run commands on a bash shell from within the container, you can run the below command. In your case it would be :
docker exec -it <container ID> bash
use docker start with '-ai' so it attaches to container interactively
docker start -ai <container ID>
CAUTION! This will relaunch the process that this container is supposed to run:
If it is defined by a Dockerfile with a CMD instruction, then it will run it.
If it was a container for building a Dockerfile, the last failed instruction will be retried.
You can try:
docker start <container name>