The Docker command is not working after restarting (using sudo reboot) the Ubuntu (20.04) server.
Now, for any command with docker, it gives me an error. For example,
$ docker --help
cannot update snap namespace: cannot create symlink in "/etc/docker": existing file in the way
snap-update-ns failed with code 1
When I manually check, there is a file called key.json in the /etc/docker folder which has a json dictionary.
Before restarting, I have had few docker containers running in the background with volume connected. When I run systemctl start docker as mentioned in one StackOverflow answer, I am getting
Failed to start docker.service: Unit docker.service not found.
It would be great at least to recover the docker images that were there before restarting.
-- Edit --
For some reason, docker is working now. I have restarted once again after the initial restart which resulted in the error. But there was no improvement. However, it is working fine now. I do not know what solved the issue, maybe the cmd journalctl -u docker.service (as suggested in a comment) help in some way, or some other reason.
So, It would be great if someone can answer what was the initial reason for the trouble? It might help us to avoid this in the future.
It looks like a Snap-related Issue.
I Found a fix on the SnapCraft forum here :
https://forum.snapcraft.io/t/layouts-still-brittle-when-refreshing-snaps/26252/5
sudo rm -rf /etc/docker
sudo snap refresh
Works in both Ubuntu 18.04.5 and 20.04.5 LTS.
To begin with, I am behind a corporate proxy. I'm using docker 1.12.0
Using OSX, my .bash_profile looks like this:
export http_proxy='http://server-ip:port/'
export https_proxy='http://server-ip:port/'
export no_proxy='localhost,0.0.0.0,127.0.0.1'
What puzzles me is that I am able to pull the ubuntu image without any problems.
docker pull ubuntu:latest
When I attempt to pull centos I get the following error:
docker pull centos:latest
latest: Pulling from library/centos
8d30e94188e7: Pulling fs layer
dial tcp i/o timeout
I've ready through this post about centos connection issues. I believe I have followed the suggested answers but still no luck.
I am able to pull the image without any problems on my personal machine, so I know it must be something with the proxy. Any suggestions are greatly appreciated!
This is painfully obvious now, and instead of turning to the internet first, I should have simply checked preference options.
In Docker for Mac, v1.12.0 once installed, click on the docker icon in the toolbar (upper right corner next to the clock) and choose "Preferences".
Under the "Advanced" tab, you can enter proxy information.
Thank you BMitch for your time, I appreciate it!
Please pull and save image on your laptop. Transfer the image to the server with no internet connection and use docker load.
Hope this works.
Setting the environment variables in your .bashrc will update the network config for any commands you run as the user. However, Docker is designed as a client/server app, and the image pulls are run from the server (dockerd). Docker has docs on how to configure systemd with a proxy that should solve your issue. In brief, you need to adjust the following:
sudo -s
mkdir /etc/systemd/system/docker.service.d
cat >/etc/systemd/system/docker.service.d/http-proxy.conf <<EOF
[Service]
Environment="HTTP_PROXY=http://server-ip:port/"
EOF
systemctl daemon-reload
systemctl restart docker
exit
If you don't have systemd installed, you should be able to edit /etc/default/docker. The entry you need to add there is export http_proxy="http://server-ip:port/".
Lastly, I'm now seeing that you're on MacOS (the question about CentOS is a red herring since I'm sure you can't pull any image and you're not actually running CentOS). In boot2docker, you have the following procedure:
boot2docker ssh
sudo vi /var/lib/boot2docker/profile
# include your "export HTTP_PROXY=http://server-ip:port/" here
sudo /etc/init.d/docker restart
exit
Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 months ago.
Improve this question
I am trying to use Docker on a windows machine and is hit with every possible issue it seems. My latest one is this:
My machine is running but I can't seem to interact with it using the docker commands. If I run a very standard command like:
docker ps
I get an error message like this:
An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v
1.23/containers/json: open //./pipe/docker_engine: The system cannot find the file specified.
So apparently some path is all messed up. Do anyone know which path this is and how to fix this?
Edit (2021) - This answer is for the old Docker Toolbox, not Docker Desktop.
When running docker ps and receiving:
An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json: open //./pipe/docker_engine: The system cannot find the file specified.
The following environment properties need to be set:
set DOCKER_CERT_PATH=%USERPROFILE%\.docker\machine\machines\default
set DOCKER_HOST=tcp://192.168.99.100:2376
set DOCKER_MACHINE_NAME=default
set DOCKER_TLS_VERIFY=1
This is assuming the %USERPROFILE%\.docker\machine\machines\default is default path where the cert.pem, key.pem, ca-key.pem, and ca.pem docker files are; the virtual machine name's (created by docker-machine create) is default and Virtual Box DHCP Server's lower bound (found under VirtualBox->File->Preferences->Network->Host-only Networks->hover mouse on VirtualBox Host-Only Ethernet Adapter) is 192.168.99.100 and no other VM is running in VirtualBox.
Same issue here on Win 7. Solution:
In the Docker Quickstart window, at the $ prompt run the below line:
your_user#your_machine MINGW64 ~
$ eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env default)
Then, you'll be able to run "docker run hello-world".
I run into this problem when using docker-machine and I haven't run the docker-machine env command after rebooting. I'm not sure how to do this in cmd.exe, but if you're using powershell try issuing this command:
docker-machine env --shell=powershell | Invoke-Expression
Make sure Hyper-V is up and running:
open elevated command prompt
type bcdedit /set hypervisorlaunchtype auto
reboot
run "Docker for Windows"
I had to deal with the same issue on Windows.
To solve it:
Create a docker machine (only if you have not got one)
docker-machine create default
Get the ENV vars which the docker client needs in order to connect to the docker machine (server) [This you will need to do every time or set in your ENV vars]
docker-machine.exe env default
You can either install them manually or run one of the following depending on your shell environment (cmd, bash, power-shell)
docker-machine env --shell=cmd # you need to run it manually
docker-machine env --shell=bash > env-var-commands-tmp && . env-var-commands-tmp && rm env-var-commands-tmp
docker-machine env --shell=powershell | Invoke-Expression
Open cmd with admin rights.
Execute following command
docker-machine env --shell cmd default
you will receive following output
SET DOCKER_TLS_VERIFY=1
SET DOCKER_HOST=tcp://192.168.99.102:2376
SET DOCKER_CERT_PATH=C:\Users\DBashyal.docker\machine\machines\default
SET DOCKER_MACHINE_NAME=default
REM Run this command to configure your shell:
REM #FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO #%i
Copy the highlighted line and execute on cmd
#FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO #%i
Execute following command
docker ps
I created a new machine using the below command
docker-machine create --driver=virtualbox vbox-test
Then executed the command
docker-machine env --shell=powershell | Invoke-Expression
Got it Working...
I had a look at all the above answers and none of them worked.
Then I found out that the command has to be run on a linux command line like bash.
so try:
Type the command into the Docker bash terminal VM that comes with the docker toolbox as opposed to the windows cmd
If you have already made sure that your docker has been started
As pointed in other answers you need to set a few environment variables.
The easiest way to do it is:
#FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd') DO #%i
This will run docker-machine env --shell cmd and add those environmental variables.
If you want these variables to be persistent defined them in windows (tutorial).
Right click the Docker icon in the tray a select "Switch to Windows containers...".
You may be prompted to enable the Containers feature. Do so and reboot, again.
To start default host in windows I know three ways given below you can use one of them.
Starting or restarting already created a default machine by the Docker:
docker-machine start default
docker-machine restart default
Now check docker-machine env
The following environment properties need to be set:
set DOCKER_CERT_PATH=%USERPROFILE%\.docker\machine\machines\default
set DOCKER_HOST=tcp://192.168.99.100:2376
set DOCKER_MACHINE_NAME=default
set DOCKER_TLS_VERIFY=1
To create a new machine using the following command:
Windows 10/HyperV:
docker-machine create --driver hyperv default
docker-machine create -d hyperv default
Mac, Linux, windows 7 & 8:
docker-machine create --driver virtualbox default
docker-machine create -d virtualbox default
I had similar issue when I installed Docker CE for Windows Version 17.11.0-ce-rc4-win39 (14244) Channel: edge e557194 on Windows 10.
In Command/cmd windows, when I tried to run commands docker ps, docker version, docker info, the I got error like “error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.34/version” every time.
To resolved this issue,
I made “Hyper-V” off (Unchecked) from “Turn Windows feature on or off”, which required the OS to be restarted.
And after first restart, I made “Hyper-V” On (Checked), which again required the OS to be restarted.
After second restart, above docker commands started working and giving proper output.
So, turning Hyper-V off and then on resolved this issue for me.
I got the solution from this issue. It not just like Nikesh's answer said SwitchDaemon could fix it directly. I think you should run this command twice to switch your daemon to your previous daemon.
cd "C:\Program Files\Docker\Docker"
./DockerCli.exe -SwitchDaemon
# then check the docker OS/Arch
docker version
# You may see the different OS/Arch
./DockerCli.exe -SwitchDaemon
# then you got your images and containers back
This command is just switch your daemon from your defualt daemon to another daemon(depends on what you set). When you switch to another daemon, the images and containers on the former daemon will disappear(but not deleted).
I have had this issue on a Windows 2016 machine. Happened because the docker service wasn't started. In my case the docker service as failing with the following error
fatal: Error starting daemon: pid file found, ensure docker is not running or delete C:\ProgramData\docker.pid
Deleting the C:\ProgramData\docker.pid file did the trick.
below resolved. i copied answer from another forum
I had this problem after update. After re-installing VB I switched on "VirtualBox NDIS6 Bridged Networking Driver" in properties network connection.
It property switched off default in my case.
Windows 10 Professional
For me the Docker service was running but Docker still needed to be 'started'. That is, I had the setting 'Start Docker when you log in' unchecked in the Docker tray icon.
Prior to finding this out I had gone to the program folder Docker and clicked 'Docker for Windows'. After a short time the message 'Docker is running' was displayed.
For me, this error was resolved after I removed daemon.json file in "%programdata%\docker\config"
The content in my daemon.json is the following:
{
"hosts": ["tcp://0.0.0.0:2375"]
}
I created this manually as part of some testing. But after I restarted the server, I started to get the error in this question.
The error is really troubling. I hope Docker Developers do something about. It took a lot of try and error to get around. Thanks to Stackoverflow and other blogs. In my case, I am using Windows 10 Pro. I settled with DockerToolbox.exe after several failed attempts with Docker for Windows Installer.exe. Then I encountered An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v . The followed these steps and the problem got solved.
First, I went to Control Panel -> Turn Windows Features On or Off and unchecked Hyper-V
Next, Open PowerShell as Admin:
docker-machine env --shell=powershell | Invoke-Expression
type bcdedit /set hypervisorlaunchtype auto
Restarted my System. Then I launched "Docker Quickstart Terminal", then I entered this on the shell window.
run "Docker for Windows"
docker run hello-world
I it went well. Then I open Command Prompt
docker run hello-world
It gave the error: Then I entered
set DOCKER_CERT_PATH=%USERPROFILE%\.docker\machine\machines\default
set DOCKER_HOST=tcp://192.168.99.100:2376
set DOCKER_MACHINE_NAME=default
set DOCKER_TLS_VERIFY=1
Most of the suggestions above too are helpful.
I saw this error message after a weekend. My setup was fine before that. My config and connections looked correct. $docker-machine restart default fixed it for me on Windows 7
I was getting this error, while running the command docker-compose up. The problem for me was, the docker service was not running. So I had to run services.msc and start the docker service.
I solved this error by run the {DOCKER_TOOLBOX_INSTALL_PATH}start.sh in bash.
In my case, all above solutions did not resolve. Instead zilurrane response helped.
cd "C:\Program Files\Docker\Docker"
./DockerCli.exe -SwitchDaemon
Switch to Windows Containers
docker info
docker ps
Switch back to Linux containers
docker info
Viola!
The windows switch likely runs the missing configurations that Linux also needs.
I was having similar issue. For me I hadn't logged in to docker from the status bar. What I did was to login to docker from status bar. Once I logged in I was able to run all the commands properly.
Try logging in using your docker id and password maybe that will resolve your issue.
I had the same issue on my Windows 10. Find below what I did to solve it:
After installing Docker, Just restart your PC, run docker application (It may require enabling Hyper-V), then open command line and type:
docker run hello-world
Everything works fine :)
I had this problem. I searched a lot. I checked many things. But in the end, the solution that solved my problem was the following solution.
System Environment:
Windows 10 Professional
Windows engine in Docker
Docker version 20.10.21
Solution
disabled IP6
And
Restarted the service and application
I am using the latest Ubuntu build 15.10 and have gone through the install of ElasticSearch here: https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-service.html
However, even after executing the command that adds the service to the start up process.
sudo update-rc.d elasticsearch defaults 95 10
sudo /etc/init.d/elasticsearch start
Rebooting the computer, then going to localhost:9200 gives a 404.
And every single morning I run the sudo /etc/init.d/elasticsearch start, then the sudo update-rc.d elasticsearch defaults 95 10 in hopes that tomorrow will be a different day, to find my machine in the exact same state as yesterday.
On a side note, my machine at work uses the same version of Ubuntu and the steps described above worked on the first try.
If anyone has overcome this issue, your insight would be very appreciated!
Thanks you!
Ubuntu, since version 15.04, is using systemd by default instead of the older upstart for handling services and init scripts. I think you need to initialize elasticsearch differently, as described in the ES docs.
Something like:
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
sudo /bin/systemctl start elasticsearch.service
After updating to Docker v1.7.0 (and also boot2docker), I'm getting the following error when running docker ps:
x509: certificate is valid for 127.0.0.1, 10.0.2.15, not 192.168.59.103
Is this a known issue with this version, and what can I do to fix this?
This is a known issue introduced in version 1.7.0 of boot2docker: https://github.com/boot2docker/boot2docker/issues/824
Update to boot2docker 1.7.1
Updating to boot2docker 1.7.1 fixes this issue, as described here.
Options for boot2docker 1.7.0
It seems to be related to the way the network interfaces are coming up during boot. The following options can be used to fix this.
Option 1
The fix is to run the following sequence, which adds code to wait for all network interfaces to be present:
boot2docker ssh
sudo curl -o /var/lib/boot2docker/profile https://gist.githubusercontent.com/garthk/d5a17007c277aa5c76de/raw/3d09c77aae38b4f2809d504784965f5a16f2de4c/profile
sudo halt
boot2docker up
Source (and more details on the code that is downloaded): https://gist.github.com/garthk/d5a17007c277aa5c76de
This has fixed the issue for me, although I had to stop the boot2docker-vm through the VirtualBox UI to get a clean start.
The Gist adds the following to the .profile file in the boot2docker VM:
wait4eth1() {
CNT=0
until ip a show eth1 | grep -q UP
do
[ $((CNT++)) -gt 60 ] && break || sleep 1
done
sleep 1
}
wait4eth1
This function waits up to 1 minute for the eth1 interface to come up.
Option 2
Another option seems to be to do
boot2docker delete
boot2docker init
boot2docker up
This will destroy the boot2docker VM - you might lose any customizations you have done.
Simply running this command fixes the issue for me. This was suggested by a Docker employee via GitHub.
boot2docker ssh sudo /etc/init.d/docker restart
Unfortunately it needs to be run each time you start boot2docker.
I've found the following "easy" alternative to work. Use a shell alias:
alias docker="docker --tlsverify=false"
Thanks to Mark Duncan.
From the troubleshooting guide:
docker-machine regenerate-certs default
docker-machine restart default
And then you're good to go, just run this as usual
eval $(docker-machine env default)