Install a package with Docker in Ubuntu - docker

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".

Related

How to build a docker image in wsl2?

I'm using docker in wsl2. I followed this guide for the setup and everything covered therein seems to work.
Now when I try to build a docker image in wsl2 with docker build . I get the error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I assume that I have to tell docker build on which IP the docker host is running (similar to docker -H 172.20.5.64 run --rm hello-world), but I have no idea how to do this?
I had the same problem, here is the solution, that worked for me:
I had to stop docker
sudo docker service stop
I had to start docker daemon
sudo dockerd
I had to stop docker daemon by pressing ctrl + z
Than i had to move the process in the background
bg %1
Then I was able to restart docker
sudo docker service start
After that, I did no longer get an error.
I hope this works for you too.

Start ssh automatically when restart docker container

I am new to Nvidia-docker. I made a container and installed tones of Softwares in it. I can SSH to the container, but every time I restart the container, I need to restart the SSH service. I want to know how to start ssh automatically.
I saw similar problems on this question saying change my dockerfile, but I do not have a dockerfile...I created it using command and installed all Softwares in it, just consider my container like a normal Ubuntu.
Thank you for replying codingwithmanny. I am using Ubuntu, just using command prompt to operate. I feel my question is more like: if I did not setup autostart ssh when setting up the docker container, what should I do now to make it up?
Its better to use docker exec -it container_name /bin/bash (or /bin/sh) instead of SSH server
https://docs.docker.com/engine/reference/commandline/exec/
https://medium.com/better-programming/docker-best-practices-and-anti-patterns-e7cbccba4f19

Docker won't run when computer restarts

The issue I am having is: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
I have had this issue before and was fixed by removing the docker group, adding again and adding myself to the group. Tried that this time, no luck.
For some reason WSL does not like it when you do a system restart and seems to stop docker from working properly. However, docker is not being helpful with their debugging...
I want to be able to restart and it work fine without having to spend hours finding a new solution that might work.
I have tried lots of solutions from adding user to group and signing out and in to tinkering with the docker socket itself, nothing is working and it is really frustrating. I think it has something to do with user groups since that was the issue last time and always has been, but the previous workaround didn't work...
I have a makefile which I used to run docker commands as it is more effecient, but even when I run docker ps I get this:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Is the docker daemon running?
The result I want is for docker to tell me that the it is starting my containers, yet it's not.
probably you should do restart the docker service by following command
sudo service docker restart
if even though it is not resolved then refer this link-->
https://docs.docker.com/install/linux/linux-postinstall/#configure-where-the-docker-daemon-listens-for-connections
I guess you already enabled docker service via sudo systemctl enable docker which will restart docker service on host restart.
Hope below references will help you fixing your issue as they look similar to yours.
Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?
https://forums.docker.com/t/cant-run-docker-in-ubuntu-14-04-cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock/31355
Solution that worked for me was to:
1)sudo groupadd docker (delete and re-add the group if it's already made)
2)sudo usermod -aG docker $(whoami)
3)sudo newgrp docker (as you cannot log-in/out again on WSL)
fixed!

Docker in docker connection error

I'm trying to run a Java application in a docker container. The application also communicates with docker. So I used docker:latest image and installed the openjdk. Now when I am running the container in interactive mode (privileged) I get the error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? when I input any docker command on the command line.
I run the container with docker run --privileged -ti con_name
Have you gone through this link? In there it's mentioned that /var/lib/docker needs to be a volume. In your docker run command, you are not mentioning any volumes. You might give this page a read and make sure everything is correct.

docker create service unavailable

I am behind a corporate firewall, running on Windows 7. I believe that I have gotten past any proxy issues (at least as far as accessing the container for which I'm trying to install.)
At this point I'm trying to execute docker's run command which 'acquires' the tensorflow package an installs it on my system.
$ docker run -it -p 8888:8888 gcr.io/tensorflow/tensorflow
C:\Program Files\Docker Toolbox\docker.exe: An error occurred trying to connect:
Post https://192.168.99.100:2376/v1.23/containers/create: Service Unavailable.
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.
I'm new to docker, (obviously) but I see that the 192.168.99.100 default docker container exists and is running.
I do see documentation regarding the 'create' service endpoint. I'm at a dead end. Any help is appreciated.
-gene
when you type docker command docker client try to connect with your local docker service. And in linux world you need a superuser privileges to connect client and service.
I don`t run docker on windows, but may be you need run docker as Administrator. like linux
sudo docker run ...

Resources