I've had Docker installed via Snap on Ubuntu 18.04 a year or so ago. I have around 5 images on there and worked quite a bit on them.
Today I get to work and the command sudo docker start 0e0
gives me:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I have not used snap in quite some time and been mostly doing apt-get updates and upgrades. Last one I did was three days ago, on Monday. I haven't used docker in that time and have restated my computer only once - yesterday.
Having forgotten I installed it via snap, I try to restart the service using systemctl start docker
and service start docker
but:
Failed to start docker.service: Unit docker.service not found.
I decide to reinstall docker and do apt-get remove docker
and apt-get install docker
. Apparently I also had it installed via apt-get, (but not worked with it?????), as the remove worked. I try systemctl
and service
again but same output. That's when I recall that I used snap to install it.
At this point I do sudo snap remove docker
, not being well accustomed with snap, I stop the process four times because it was taking too long - unbeknownst to me it was creating a snapshot. The fifth time it created it successfully. I run: sudo snap install docker
. Docker works, ps -a
returns an empty list, so does images
.
When I see all the container and volume data gone, I realise snap create a snapshot and run sudo snap restore 5
. Data is restored, but docker images
still returns an empty list. Thinking it needs a restart, I do sudo snap restart docker
.
Docker restart successfully, doing ps -a
returns:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Back at the starting point.
Running snap logs docker
, returns:
2020-08-27T09:19:35Z systemd[1]: Started Service for snap application docker.dockerd.
2020-08-27T09:19:36Z docker.dockerd[24590]: failed to start daemon: Error saving key file: open /etc/docker/.tmp-key.json485929544: no such file or directory
2020-08-27T09:19:36Z systemd[1]: snap.docker.dockerd.service: Main process exited, code=exited, status=1/FAILURE
2020-08-27T09:19:36Z systemd[1]: snap.docker.dockerd.service: Failed with result 'exit-code'.
2020-08-27T09:19:36Z systemd[1]: snap.docker.dockerd.service: Service hold-off time over, scheduling restart.
2020-08-27T09:19:36Z systemd[1]: snap.docker.dockerd.service: Scheduled restart job, restart counter is at 5.
2020-08-27T09:19:36Z systemd[1]: Stopped Service for snap application docker.dockerd.
2020-08-27T09:19:36Z systemd[1]: snap.docker.dockerd.service: Start request repeated too quickly.
2020-08-27T09:19:36Z systemd[1]: snap.docker.dockerd.service: Failed with result 'exit-code'.
2020-08-27T09:19:36Z systemd[1]: Failed to start Service for snap application docker.dockerd.
That log was around the time I tried to start the container I wanted to use (having realised I restarted the computer the day prior).
Docker is version: Docker version 19.03.11, build dd360c7
after doing the snap re-install and restore.
What should I do to have a working docker, preferably through snap (now that I know how it works I quite like the concept), and restore all the images that are still on the disk?
Can I, for example, create a clean new installation via apt-get and "import" the images, volumes and containers I have on my disk?
P.S. In general I'm writing this question so meticulously due to two factors: 99% of the questions and answers I found on docker not being able to connect to the docker daemon were either not installed via snap or were fresh installations.
EDIT:
27-08-2020 12:13
The folder /etc/docker doesn't exist at all and the docker installation is in /var/snap/docker
Doing sudo systemctl stop snap.docker.dockerd.service
and sudo systemctl start snap.docker.dockerd.service
finds the services but docker returns the same error. sudo snap services docker
returns:
Service Startup Current Notes
docker.dockerd enabled inactive -
What's more bizzare, is that sudo snap start docker
gives Started.
and running services
again gives
Service Startup Current Notes
docker.dockerd enabled active -
but when I do sudo docker ps -a
and check services
, Current goes back to inactive.
27-08-2020 14:06
After actually and properly installing docker-ce via apt-get I have realised I didn't have docker fully installed previously. I'm trying to find if moving images, containers and volumes from snaps directory to apt-gets docker is possible. Haven't found an answer yet.