I have an ubuntu 18.04 running on a metal server. My docker working good but one day i can not build new docker image, my build script hang without showing any error (the script working good before).
I tried to restart docker engine by: sudo systemctl restart docker but docker service can not active, the command: sudo systemcle stop docker not working too.
Then i rebooted my server then docker go back.
What log files should i check to know what make my docker service hang?
You can view the docker service logs using:
sudo journalctl -fu docker.service
I'm unable to start docker service in ubuntu 18.04.
How do I install docker, and how do I start the start docker service?
When running systemctl start docker I got this error:
System has not been booted with systemd as init system (PID 1). Can't operate.
This is the error related to Ubuntu Linux service error, not by Docker
You Can Use
sudo service docker start/status/stop instead of systemctl
Instead, use: sudo service docker start
Docker doesn't require any explicit commands to start its service.
Kindly use steps shared in below like for Setting up docker in Debian i.e Linux machine
https://docs.docker.com/engine/install/debian/
you can get rid of using sudo for every command by doing this Manage Docker as a non-root user
I am currently trying to download Hyperledger Fabric through Ubuntu 20.04. I downloaded ubuntu through the windows store. I have also downloaded docker desktop and set up WSL 2 backend for Ubuntu. However, after installing docker.io through the ubuntu terminal using
sudo apt-get install docker.io
I was trying to enable it. As ubuntu was using Sysvinit instead of systemd i used the following to try and enable docker.
sudo service docker start
which returned
docker: unrecognized service
I am new to linux so any suggestions or anything obvious I have missed that will fix this issue would be appreciated
Thanks
The ubuntu distribution that runs in WSL differs from normal ubuntu in key ways. One of them is that it doesn't have the standard linux initialization system.
service: starts services defined in the SysV init system. If you do ls /etc/init.d/ you will see services. When I look in my WSL installation, I see cron. So this works (but probably doesn't survive a reboot):
sudo service cron start
There is no init script for docker, so that won't work.
systemctl (systemd): starts services defined in the systemd system. This is probably what you want, except, if you run:
sudo systemctl start docker
you get:
System has not been booted with systemd as init system (PID 1). Can't operate.
So, you'll need to start docker manually, not using the normal initialization systems.
This leads us to the real answer:
https://docs.docker.com/docker-for-windows/wsl/
According to the docker docs, you don't run docker as a service on linux. Install docker on windows and let it interact with the docker engine on WSL to run your containers.
For me a simple restart of Windows solved this issue:
I'm using Ubuntu in WSL2 and I'm trying to start a container inside the WSL2, and it gives me this error:
Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:8443 -> 0.0.0.0:0: listen tcp 0.0.0.0:8443: bind: An attempt was made to access a socket in a way forbidden by its access permissions.
Hello I'm stuck with an issue with docker. After forcing my laptop to shut down, docker which was working fine before now spits out the following error
docker-compose build && docker-compose up
dev_db uses an image, skipping
Building dev_server
ERROR: Couldn't connect to Docker daemon - you might need to run docker-machine start default.
I get an error on running docker-machine start default (both with sudo and without), and as I try to create a new machine with docker-machine create default, I run into the following. docker itself is still installed as I can see the commands as I enter docker.
Running pre-create checks...
Error with pre-create check: "VBoxManage not found. Make sure VirtualBox > is installed and VBoxManage is in the path"
sudo service docker restart results in the following
Failed to restart docker.service: Unit docker.service not found.
and sudo docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
and systemctl status docker.service
Unit docker.service could not be found.
I also tried restarting my laptop and logging in and out again. I'm really puzzled by this and I'd appreciate any help!
Docker is installed but the daemon is not!
There are many reasons why the devil may not be running
Maybe is storage driver
Try this steps first
Disable Docker service: sudo systemctl stop docker.service
And then start Docker Daemon (overlay driver): sudo docker daemon -s overlay
Then edit /etc/default/docker file and add the option:
DOCKER_OPTS="-s overlay"
I am trying to run a docker example following this documentation
This is my command:
docker run -d -p 80:80 --name webserver nginx
But I get this error:
docker: Error response from daemon: driver failed programming external connectivity on endpoint webserver (bd57efb73c738e3b271db180ffbee0a56cae86c8193242fbc02ea805101df21e): Error starting userland proxy: Bind for 0.0.0.0:80: unexpected error (Failure EADDRINUSE).
How do I fix this?
From your error message, the EADDRINUSE indicates port 80 is already in use on either the docker VM or possibly directly on your laptop. You can either stop whatever is running on that port, or change the port used in your Docker, command. To change to the external port 8080, use:
docker run -d -p 8080:80 --name webserver nginx
If you are the port i not in use, try restarting docker. That usually works for me.
I had the same issue with one of my containers. I tried everything but when nothing worked, I tried the following and launched the container again with success
sudo service docker stop
sudo rm /var/lib/docker/network/files/local-kv.db
sudo service docker start
Try restarting the docker service. It works 99% of the time.
service docker restart
If that didn't work as expected, try restarting your pc and then restarting the docker service using above command.
If none of the above worked try changing the exposed port to another unused port that should work.
docker run -d -p 81:80 --name webserver nginx
Note :- 81 is the port on your host and 80 is the port on your docker container
For the first time, when i made a docker simple web app, i also faced same problem.
Simply you can try the following steps to resolve the problem and also able to understand the reason why you had faced the problem in details.
Step-1: check all the running containers using the command:
docker ps
Step-2: Find out the container id of the container which is running on the same port, you are trying to reach.
Step-3: Stop the container which one is running on the same port using this command:
docker stop <container id>
Step-4: Again build the container:
docker build -t DockerID/projectName .
Step-5: Again try to run your container on the same port using port mapping.
docker run -p 8080:8080 DockerID/projectName
Try this command:
sudo service docker restart
If it does not help, restart your server.
Stop all the running containers docker ps -a -q then
Stop the Docker on your machine & restart it.
Recently this problem started to happen a lot on Windows. You can try restarting docker or you can manually stop docker before Windows shutdown - docker starts cleanly on reboot. On 7/24/2018 docker issue is open and further details can be found at https://github.com/docker/for-win/issues/1967
Check what's on port 80 right now - sudo ss -tulpn | grep :80
You may have apache2 running.
You can check it - sudo service apache2 status
If so - sudo service apache2 statop
If you tried all above solutions and still having issues, you can kill LISTEN ports manually as below for Linux users
sudo lsof -i -P -n | grep LISTEN
sudo kill -9 <process_pid> (ex. sudo kill -9 28563 28575 28719 28804)
In my case, port 80 is the default port for the web server and therefore it is protected. I changed the bind to port 60:8080 to ensure no deeper issues. Changing the bind to a different port allows me to execute the docker run and hit it in the browser at http://ip:60
I had same problem with same error.
As long as I had a local nginx installed in my computer, running another nginx through the container made conflict in port :80.
Simply I tried to stop the service of my local installed nginx as below:
sudo service nginx stop
Then after, I could run nginx by docker-compose up -d without any problem:
Creating MyWebServer ... done
Creating mongo ... done
Creating redis ... done
For me, a simple
ddev poweroff
fixed this.
If this case is with Redis: remove the ports - ... in the docker-compose file and let it assign by itself. or change the port mapping in the host from 6379:6379 to 6378:6379 that worked for me.
windows users: docker description
On Windows systems, CTRL+C does not stop the container. So, first type
CTRL+C to get the prompt back (or open another shell), then type
docker container ls to list the running containers, followed by docker
container stop to stop the container.
Otherwise, you get an error response from the daemon when you try to
re-run the container in the next step.
I had the same problem, I thought with CTRL+C stoped the container but it was not the case, any af the answer above works because they all stop containers, restarting docker or stoping container explicity.
I prefer:
docker container ls #list containers running
docker stop [container id] #replace [container id] with the container id running
This seems to be an incompatibility problem with windows "fast-boot" as described here: (just restart the docker service) and it may work.
https://github.com/docker/for-win/issues/2722
This is caused by an incompatibility with Docker and fastboot. You can either make sure you stop all containers before shutting Windows down or you can disable fastboot in Windows' power settings by doing the following:
CTRL+R > "powercfg.cpl" > "Choose what the power buttons do" > "Change settings that are currently unavailable" > Deselect "Turn on fast start-up"
You can also disable fastboot with a single command in powershell if you're comfortable doing so:
Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power\' -Name HiberbootEnabled -Value 0
If you are using WSL, after i tried all above and still it doesn't work, i tried to restart the WSL from Powershell with admin privileges and shutdown command:
wsl --shutdown
That worked for me.