I'm running Docker version 20.10.5 on a Centos 7 Box. I stopped my project with docker-compose down and every container had the same message -
Error response from daemon: container <container ID>: driver "overlay2" failed to remove root filesystem: unlinkat /var/lib/docker/overlay2/<long number>/merged: device or resource busy
I've stopped the daemon, I've reinstalled Docker, I've tried umount, lsof, kill, and all the docker go-away commands including system prune but still they hang on.
(After re-installing Docker the status changes to Dead. When I try to delete the zombie containers their status changes to Removal In Progress)
How can I get rid of these containers?
For people who have similar issues:
So I had similar issue where
docker rm -f <docker name> was hanging
The only thing that helped me was:
service docker restart
On Ubuntu 22.04 with Docker engine 23.0.0 neither stopping/starting the Docker service nor a docker system prune removed the containers (still showing Removal in progress). The solution as outlined here was to manually remove the volumes associated with the container(s):
sudo service docker stop
sudo -i
cd /var/lib/docker/containers
rm -rf <container id>
sudo service docker start
I'm trying to start up my docker but upon investigation I realized it can't start because there isn't enough space on the server. I would have run the sudo docker system prune -a -f --volumes command but it won't go through because docker isn't running and most of the space is taken by docker images and logs. Where can I find these logs and dangling images to delete on the server manually?
I've downloaded two docker containers and already configure them.
So, now all I want is to start them on system startup.
They are in a path like
/home/user/docker-mailserver
/home/user/docker-webserver
Hosted on a Ubuntu 18.04.01 (x64)
On boot those docker containers are not running.
On login, those docker containers are starting.
I already tried to do something like
docker run -it --restart unless-stopped fancydockercontainer:latest
docker run -dit --restart unless-stopped fancydockercontainer:latest
But then when I do docker ps there where new containers added to the pool.
Is there a way to "re-route" the start process of those container to system start without completely delete / remove them?
Addition:
I started them like docker-compose up -d mailserver
After #KamilCuk gave a hint to solve this with service, this was a possible solution.
Looks like this:
Create service file with command:
nano /etc/systemd/system/docker-mail.service
Done stuff like that in the file
[Unit]
Description=Docker Mailserver
Requires=docker.service
After=docker.service
[Service]
Restart=always
RemainAfterExit=yes
WorkingDirectory=/home/user/docker-mailserver
ExecStart=/usr/bin/docker-compose up -d mail
ExecStop=/usr/bin/docker-compose stop -d mail
[Install]
WantedBy=default.target
Adding the new service to systemctl with systemctl enable docker-mail.service
After rebooting the server, this mailserver is available.
At this point, I was able to see the startup log with journalctl -u docker-mail.service -b (-b is just "boot")
I would like to restart a docker container, after exiting it and rebooting, with the same runtime with which it was initially created.
Here's what I did so far.
Create the container:
sudo docker run --runtime=nvidia [...]
Restart Docker after exiting the container and rebooting:
service docker restart
Restart the container previously created:
sudo docker start my_container
Reopen the container.
docker exec -it my_container [...]
The program which is then launched in the container doesn't use the Nvidia GPU as expected. It instead uses the system CPU.
Any help would be greatly appreciated.
I got the expected result by creating a new container with the --restart=unless-stopped policy, which lets Docker restart the container by itself when the Docker service is restarted. There seems to be more that's being done in this process than the start/exec sequence that I was using.
I'm going through this tutorial
making docker image with: docker build -t myapp_back .
and then want to run container with: docker run -p 3000:3000 -d myapp_back
it's simlpe node/express app
But I'm getting an error:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error
response from daemon: driver failed programming external connectivity
on endpoint wizardly_wescoff
(a7c53e0d168f915f900e3d67ec72805c2f8e4f5e595f6ae3c7fed8e097886a8b):
Error starting userland proxy: mkdir
/port/tcp:0.0.0.0:3000:tcp:172.17.0.2:3000: input/output error.
What's wrong?
my dockerfile:
FROM node:carbon
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ['npm', 'start']
and start in package.json:
"start": "nodemon src/app.js --exec babel-node"
To solve the following error in Windows: just Restart Docker (from tray menu or selecting the 'Restart Docker...' option in Settings/Reset)
Cannot start service YOUR_SERVICE: driver failed programming external connectivity on endpoint ...
Looks like it is a known issue from docker: https://github.com/docker/for-win/issues/573
Try:
disabling "Experimental Features" in the Settings/Daemon menu
restarting docker
stopping all containers.
To stop all containers, run: docker ps -a -q | ForEach { docker stop $_ }
EDIT: Working ShellScript code to Stop All Containers
for a in `docker ps -a -q`
do
echo "Stopping container - $a"
docker stop $a
done
Just restarted my computer and it works now..
I am able to get docker working on my windows 10 pc by resetting docker to the factory defaults. Restarting docker, restarting my machine did not work.
On Mac Mojave, run the following command to find which processes are using the port.
sudo lsof -i #localhost:<port_no>
In my case I was checking port 8080 so I run
sudo lsof -i #localhost:8080
I found that the http-alt is running on port 8080 and after getting the process id using above command you can kill the processes by
sudo kill -9 <process_id>
However, in my case four applications ArtemisSe, Mail, Google and Slack are using http-alt on port 8080. Since they look important applications so I changed my port and run the container on 8888 instead of 8080. i.e.
docker run -it --rm -p 8888:8080 <imageid or image name>
Restarting the computer is not the actual fix, just a workaround, that one would need to be doing on a frequent basis.
The problem is related with the default windows 10 shutdown behaviour.
The actual fix can be achieved disabling windows fast startup settings:
Control Panel -> Power Options -> Choose what the power button does -> Change settings that are currently unavailable -> Toggle Turn on fast startup
I am running under linux. If I run docker as root with the sudo command, it works fine.
Just restart docker, right click on its icon then restart. that solved my problem
In my case, the same error in PHP Container. I solve changing the public port and works.
This command throw error after restart my Windows 10:
docker run -d -p 8080:80 --name php_apache php_app
Solution:
docker run -d -p 8081:80 --name php_apache php_app
Just run this command to stop your all containers
It worked for me.
for a in docker ps -a -q
do
echo "Stopping container - $a"
docker stop $a
done
In some case,restarting your computers solve problem. But it is not really best solution, especially UNIX like operation system.
First of all you should know other process is either running or not in specific port, If you see such port is already in use by other resources. you should kill that procees which running in that port. To do that just follow:
sudo lsof -i #localhost:<port number>
Output looks like this
Command PID USER TYPE SIZE ...
<command> <pid number>
We need pid number which is defines procees id
And then kill that process by its procees id
sudo kill -9 <pid>
After kill that procees you can run your new container in such port as you want