docker installation in ubuntu and start problem - docker

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

Related

How to check docker service logs when restart and stop by: sudo systemctle restart docker or sudo systemctl stop docker?

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

Building a docker image on wsl

I got a new machine and am now using wsl for the first time instead of just ubuntu. I am trying to rebuild one of my projects, but I am unable to build the docker image.
When running docker-compose build I get the error:
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
I have tried running:
systemctl start docker
But then I get the error:
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
Can anyone tell me what im doing wrong , please and thank you.
From WSL you actually want to use Docker from the Windows host:
Install Docker Desktop for Windows
Go to the settings > Resources > WSL Integration and flip the switch for the Distros where you want Docker enabled.
You should now be able to run docker -v in your WSL commandline and get an output of the Docker version

Docker not working Ubuntu 20.04 on windows

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.

Install a package with Docker in Ubuntu

I want to install a package by docker, following instruction in: https://dynamic-fba.readthedocs.io/en/latest/installation.html#installing-from-source
I installed ubuntu and then Docker. But I don't understand what I need to do next. There it is said to type (docker run -it -v ${PWD}:/opt/examples davidtourigny/dfba python3 examples/example1.py). I excatly type it in ubuntu but I get this error:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
Using alternative method of dockerfile, I also get error. I don't know how to make use of make build, but used build instead following tutorials on the web.
It's my first time using Docker and I don't know what to do.
Any help is very appreciated.
The Docker application has two components, a back-end server, and a front-end cli. This way you can do cool stuff like control Docker remotely or have orchestration frameworks that manage multiple Docker nodes over the network like Kubernates.
For security, the Docker back-end server is not exposed on a normal TCP port but it uses a unix domain socket (Linux magic that makes a file act as a port) at unix:///var/run/docker.sock.
When you execute docker run -it ... the cli application will attempt to connect to the backend server, but it looks like the daemon/server is probably not running.
Try to check that daemon is running. If you are using systemd you can check with
systemctl status docker and start if is stopped with systemctl start docker finally it might be good to enable it to make sure it starts automatically on reboot, you can do that with systemctl enable docker
Make sure to start docker service (you can either go for systemctl start docker or reboot your computer).
Once this is done, it is likely that your user has no permissions to communicate with Docker without sudo. Docker has privileged access to your hardware and therefore giving a user the docker group is required for security reasons.
Run:
sudo usermod -aG docker $USER
groupadd docker
docker run hello-world
This will add you to docker group, reflect the changes inmediately and run a sample image from Docker.
If all was okay, the last command should tell you "Hello from Docker".

Couldn't connect to Docker daemon on ubuntu

I am using docker-compose-version 1.7.0,
Not using docker machine:
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
it all worked perfectly for weeks...
Now when i try running
docker-compose up
i get this error:
Couldn't connect to Docker daemon-you might need to run docker-machine start default.
I cant figure out what happened, any ideas?
Run it with sudo.
Its bad to run docker with sudo so you should add your user to the docker group
https://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo

Resources