I'm trying to run a docker daemon on ubuntu 14.04. I have a private registry running on the same host on port 5000. The registry is running on http, not https, which is fine for my purposes.
When I try to start the docker daemon with sudo service docker.io start, I see this error in syslog:
kernel: [9200489.966734] init: docker.io main process (9328) terminated with status 2
/etc/default/docker.io has just this one option
DOCKER_OPTS="--insecure-registry 192.168.0.100:5000"
When I try to start the daemon by hand with sudo docker.io --insecure-registry 192.168.0.100:5000 -d I get an error message saying flag provided but not defined: --insecure-registry
I've read the documentation on this, and it looks like I'm doing everything right, but clearly I'm missing something. What am I doing wrong?
I have a feeling you are running docker v1.2 not v1.3 - you might need to update your docker version, take a look at docker -h and see if the flag is available.
Related
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".
I'm running Docker from within a container, which I start like so:
docker run -d `
-v //./pipe/docker_engine://./pipe/docker_engine `
-v "$($dockerpath):C:/docker"
From within the container, I can run docker ps just fine and it returns the running containers on the host engine.
However, when I run docker-compose, I get the error:
Couldn't connect to Docker daemon. You might need to start Docker for Windows.
This worked fine back when I used TCP/TLS to connect to the Docker engine. The problem started when I switched to using named pipes.
Any ideas how to fix?
If anyone comes across this post: I had the same problem. I'm using docker-toolbox and noticed an error message in the terminal:
Error getting IP address: Something went wrong running an SSH command!
command : ip addr show dev eth1
err : exit status 255
output :
docker is configured to use the default machine with IP For help getting started, check out the docs at https://docs.docker.com
The solution was to reconfigure the default virtual machine. Run these commands in a terminal:
$ docker-machine rm default
$ docker-machine create --driver virtualbox default
Then run Docker Quickstart Terminal.
BTW, if you then come across an issue that the docker start is stuck at "Waiting for ip..." please follow this post for the solution.
I've been going through the docker tutorial at https://docs.docker.com/v17.12/get-started/part3/#take-down-the-app-and-the-swarm and am up to the part where we're setting up our initial docker swarm.
I had this working at first, but then had to reconcile differences between a snap install docker and apt install docker on my system. Following this, when I try to run docker swarm init I'm told:
Error response from daemon: manager stopped: failed to listen on remote API address: listen tcp 0.0.0.0:2377: bind: address already in use
I have no other docker images or services running, so I'm fine killing or deleting anything, but I can't seem to figure out how to clear up this port so that I can initialize a new swarm.
Is there a way to either A) Kill the running swarm, or B) List the available swarms so that I can join it and then kill it from there as a swarm master?
Thanks!
Seems like you have installed docker from both snap/apt and you must uninstall one of the two (one is running in swarm mode and the docker client is connecting to the one that isn't).
To find the process running swarm use the following:
sudo ss --tcp --listening --processes --numeric | grep ":2377"
This will list the processes listening on the port 2377, on my case i find:
LISTEN 0 128 *:2377 *:* users:(("dockerd",pid=1229,fd=24))
Now using the pid you can find the process location:
sudo readlink -f /proc/1229/exe
If the process comes from a snap then you know that you must stop it and remove the snap so it only leaves the inastallation from apt-get (or viseversa if you want to keep the snap installation).
On my machine, I had to restart docker:
systemctl restart docker
And then it started to work again.
After removing the snap package with sudo snap remove docker I got the error docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
After trouble shooting, the solution was to uninstall, reinstall the apt docker packages and then restart the docker service with systemctl restart docker I confirmed it worked with journalctl -xe and sudo docker run hello-world
I installed docker on an Ubuntu 16.04 following the official directions and am successfully running the registry as a container. I want to remote connect into another container, so I try:
docker -H tcp://1.2.3.4:2375 exec -it 19f36d1bdfaf /bin/bash
And I get an error:
error during connect: Post
http://1.2.3.4:2375/v1.29/containers/19f36d1bdfaf/exec: dial tcp
1.2.3.4:2375: connectex: No connection could be made because the target machine actively refused it.
Why am I getting this error and how do I resolve it?
The docker.json file has contents:
{
"hosts": [
"tcp://0.0.0.0:2375",
"npipe://"
]
}
When I view the services it looks like the daemon is not listening on tcp://0.0.0.0:2375 as I would expect (this is just for testing, I'm going to secure this once I can get it actually working):
UPDATE:
Got it to partially work by creating a daemon.json file (a copy of docker.json), then running:
sudo dockerd
The problem with this is that now the client does not work: docker info results in an error:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
UPDATE and SOLUTION:
Andreas' answer helped me realize the daemon was not being run properly. Looking at that screenshot earlier in this post, the docker daemon was not being launched with the right -H option. I then found this Github issue which solved the problem. So all that was needed was:
Edit the $DOCKER_OPTS variable in /etc/default/docker: DOCKER_OPTS="-H tcp://0.0.0.0:2375" (note that this is not very secure, it's just for testing)
Edit the /lib/systemd/system/docker.service file by adding a line under [Service] for the EnvironmentFile: EnvironmentFile=-/etc/default/docker then update the ExecStart line: ExecStart=/usr/bin/dockerd $DOCKER_OPTS -H fd://
Restart the service sudo service docker restart
Restart the daemon with systemctl daemon-reload
Note that I did not add a daemon.json file -- I left the existing docker.json file.
By default the docker daemon isn't exposed to the outside world for security reasons. You can of course change this setting when starting your docker daemon with the -H flag.
To test it out, you can simply start your daemon manually (be sure to stop the service before). Assuming 1.2.3.4 is the ip of the host running the daemon you want to connect to.
<path to>/dockerd -H tcp://1.2.3.4:2375
Or you bind it to all network interfaces:
<path to>/dockerd -H tcp://0.0.0.0:2375
You can provide more than one -H option here to not disable the unix socket when binding to the tcp socket. For details on the daemon binding options, please see the docs (Bind Docker to another host/port or a Unix socket).
To have this permanently, you can configure your daemon startup settings in a daemon.json file where you can also specify an array of hosts. Please see the docs (Configure the Docker daemon) and Linux configuration File for this, too.
{
"hosts": [
"tcp://0.0.0.0:2375",
"unix:///var/run/docker.sock"
]
}
You can provide a list of entries for hosts, so your daemon can listen to tcp and the unix socket at the same time.
Please be aware that by just binding to tcp 0.0.0.0 anyone that is able to reach your machine is also able to start containers remotely and thus is almost able to do anything on your system like with a really bad root user password. You should only do this for testing or in an environment that is isolated / firewalled correctly.
Andreas' answer helped me realize the daemon was not being run properly. Looking at that screenshot earlier in this post, the docker daemon was not being launched with the right -H option. I then found this Github issue which solved the problem. So all that was needed was:
Edit the $DOCKER_OPTS variable in /etc/default/docker: DOCKER_OPTS="-H tcp://0.0.0.0:2375" (note that this is not very secure, it's just for testing)
Edit the /lib/systemd/system/docker.service file by adding a line under [Service] for the EnvironmentFile: EnvironmentFile=-/etc/default/docker then update the ExecStart line: ExecStart=/usr/bin/dockerd $DOCKER_OPTS -H fd://
Restart the service sudo service docker restart
Note that I did not add a daemon.json file -- I left the existing docker.json file.
I just installed Docker on mu Ubuntu 14.10 64 bit OS and I followed the steps to create the necessary certificates and keys so that I can secure my docker http remote connections. When I tried to issue the following command,
sudo docker --tlsverify --tlscacert=ca.pem --tlscert=cert.pem --tlskey=key.pem -H=x.x.x.x:2376 version
I get to see the following error message:
Cannot connect to the Docker daemon. Is 'docker -d' running on this host
The -H=x.x.x.x is the host as I see when I did a ifconfig and found the host from the docker0 entry that was listed.
Please help me identify why I'm not able to do anything with my daemon.
Did you change the options on the daemon itself? Paraphrasing the docs:
You can listen on port 2376 on all network interfaces with -H tcp://0.0.0.0:2376, or on a particular network interface using its IP address: -H tcp://192.168.59.103:2376.
To do this you could edit /etc/init/docker.conf and update the DOCKER_OPTS variable
Sometime ago i had this issue :
"Cannot connect to the Docker daemon at tcp://127.0.0.1:2376. Is the docker daemon running?"
Looking an your question, you did not specify if you are working on Ubuntu WSL (Bash).
Regardless of your env configuration.
Looking for the file ".bashrc" in your
add the following to it
export DOCKER_HOST=tcp://192.168.59.103:2376
Happy Devops!