Docker on machine using a ramdisk doesn't work - docker

My machine that boots on a ramdisk cannot start a docker container.
For example, running hello-world results in
$ docker run hello-world
docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:430: container init caused \"rootfs_linux.go:109: jailing process inside rootfs caused \\\"pivot_root invalid argument\\\"\"": unknown.
ERRO[0000] error waiting for container: context canceled
Unfortunately, the DOCKER_RAMDISK=true variable does not seem to have an effect. I set it before restarting the docker service with systemctl restart docker but with no effect.
(I'm on Debian Buster)

If the setting applies to dockerd, then try configuring this in systemd (should just be able to copy/paste the following into a root shell):
mkdir -p /etc/systemd/system/docker.service.d
cat >/etc/systemd/system/docker.service.d/10-ramdisk.conf <<EOF
[Service]
Environment=DOCKER_RAMDISK=true
EOF
systemctl daemon-reload
systemctl restart docker

Related

Cannot stop a docker container

I am very new to docker. I am following a tutorial on it.
I can successfully build and run my docker container.
docker build .
docker run -p 3000:3000 3cd35580990c
But when I try to stop the container
docker stop ef485ea0dabd
Error response from daemon: cannot stop container: ef485ea0dabd: Cannot kill container ef485ea0dabda4939e7cc371408937174bf282a82e169c0fc71c2cf2b0b7bf74: unknown error after kill: runc did not terminate sucessfully: container_linux.go:392: signaling init process caused "permission denied"
: unknown
I got this long error about permission denied.
How can I solve this?
Your stop command is correct if you only want the container to stop. That won't remove the container though. To remove a stopped container you should use
docker container rm <id>
If the container is running (rather than stopped) you can force its removal using
docker container rm -f <id>
You can kill and remove all containers (running and stopped) using this command:
docker container rm -f $(docker ps -qa)
To see what containers you currently have you can use:
docker ps
But that only shows running containers. If you want to see stopped containers too you can do this:
docker ps -qa

Docker OCI runtime create failure

When I run "docker run -it python:3" in a Ubuntu 18.04.1 LTS server, I got the following error. What does this mean and how do I fix this?
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"process_linux.go:385: running prestart hook 0 caused \\\"fork/exec /usr/bin/dockerd (deleted): no such file or directory\\\"\"": unknown.
Restart docker service.
I was also facing same issue. Solve it by restarting docker service:
sudo systemctl restart docker
Same described here,
https://github.com/moby/moby/issues/29640#issuecomment-273617532
For those of you who might have installed using snap, this will restart all docker services:
sudo snap restart docker
Or, for just the daemon, use:
sudo snap restart docker.dockerd

Docker unable to stop container

I am using docker version Docker version 18.09.0, build 4d60db4 in a Ubuntu 16.04 system. I am unable to stop a docker container. My docker image contains a spring boot application. I am using the following command to stop the container:
sudo docker stop 0c6b70fcb25e
And I am getting the following error:
Error response from daemon: cannot stop container: 0c6b70fcb25e:
Cannot kill container 0c6b70fcb25e0b0c55f123853654cd2611e3702fdf5622bd07e12a92efa3df46:
unknown error after kill: runc did not terminate sucessfully:
container_linux.go:393: signaling init process caused "permission denied": unknown
I have tried running docker stop with and without sudo.
Try this:
docker kill --signal=SIGHUP my_container
You can find more information here.
Also, if you are on Linux, AppArmor may prevent stopping the containers. Disable AppArmor temporarily and try to stop the container again. For configuring the AppArmor check this link.
Follow this link. docker on ubuntu 16.04 error when killing container
I used the following commands and it worked.
sudo killall docker-containerd-shim
sudo docker-compose down

Failed to enter to a docker container, created with kubernetes deployment

With minikube i created simple deployment (https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#creating-a-deployment) in the kubernetes. I'm sure that container must running , because kubernetes pod was started successfully and I can see container running in the Portainer. But I just can't enter into the container!!
(I always could do it with a simple pod, maybe with deployment something wrong)
$ docker exec -it 01a7c90b4267 /bin/bash
rpc error: code = 2 desc = oci runtime error: exec failed: dial unix /tmp/pty870274210/pty.sock: connect: connection refused
Also I found "Error syncing pod" in the container logs, but the container status is running
bash isn't available in your container. Have you tried with sh?
$ docker exec -ti 01a7c90b4267 sh
Also, if you're attaching to a running container within Kubernetes, you probably want to kubectl exec instead of docker exec:
$ kubectl exec -ti <pod_id> sh
It seems that the problem was caused by mounting to the minikubes' tmp folder minikube mount $TMP:/tmp. Without mounting I can exec the /bin/bash in the containers with no problems

Failed to connect to containerd

I ran a command like this in a docker-in-docker (dind) scenario:
docker daemon --host=unix:///var/run/docker.sock --host=tcp://0.0.0.0:2375 --storage-driver=overlay
And I got this in the logs:
INFO[0000] libcontainerd: new containerd process, pid: 18
FATA[0000] Failed to connect to containerd. Please make sure containerd is installed in your PATH or you have specificed the correct address. Got error: write /proc/18/oom_score_adj: permission denied
Be sure to run the container in privileged mode.
docker run --privileged ...
This should fix the problem; you should now be able to install and run Docker inside this Docker image.

Resources