Can't uninstall docker-ce (and can't install any new programs) - docker

I messed up my docker install on WSL Linux (Ubuntu 16.04.5 LTS). I have tried uninstalling it but it refuses to budge. Here are issues:
First checking if docker exists:
$ dpkg -l | grep -i docker
pFR docker-ce 5:18.09.4~3-0~ubuntu-xenial amd64 Docker: the open-source application container engine
Trying to remove docker-ce:
$ sudo apt-get purge -y docker-ce
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
docker-ce*
0 upgraded, 0 newly installed, 1 to remove and 146 not upgraded.
1 not fully installed or removed.
After this operation, 85.4 MB disk space will be freed.
dpkg: error processing package docker-ce (--purge):
package is in a very bad inconsistent state; you should
reinstall it before attempting a removal
Errors were encountered while processing:
docker-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)
And the coup de grâce - trying to install any new program:
$ sudo apt-get install sysvbanner
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
docker-ce : Depends: docker-ce-cli but it is not going to be installed
Depends: containerd.io (>= 1.2.2-3) but it is not going to be installed
Recommends: aufs-tools but it is not going to be installed
Recommends: cgroupfs-mount but it is not going to be installed or
cgroup-lite but it is not going to be installed
Recommends: pigz but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
And trying to fix the install with apt-get -f install as recommended:
$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
containerd.io docker-ce-cli
The following NEW packages will be installed:
containerd.io docker-ce-cli
0 upgraded, 2 newly installed, 0 to remove and 146 not upgraded.
1 not fully installed or removed.
Need to get 0 B/50.3 MB of archives.
After this operation, 157 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Selecting previously unselected package docker-ce-cli.
(Reading database ... 69776 files and directories currently installed.)
Preparing to unpack .../docker-ce-cli_5%3a18.09.4~3-0~ubuntu-xenial_amd64.deb ...
Unpacking docker-ce-cli (5:18.09.4~3-0~ubuntu-xenial) ...
Selecting previously unselected package containerd.io.
Preparing to unpack .../containerd.io_1.2.5-1_amd64.deb ...
Unpacking containerd.io (1.2.5-1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up docker-ce-cli (5:18.09.4~3-0~ubuntu-xenial) ...
Setting up containerd.io (1.2.5-1) ...
dpkg: error processing package docker-ce (--configure):
package is in a very bad inconsistent state; you should
reinstall it before attempting configuration
Errors were encountered while processing:
docker-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)
Pls. halp. If I maybe so informal.

I solved the problem with following commands:
sudo apt-get install docker-ce
sudo apt-get purge docker docker.io docker-ce
sudo apt autoremove
then I can install new programs:
sudo apt-get install php -y

Related

error in docker build - Err:1 http://deb.debian.org/debian stretch/main amd64 unzip amd64 6.0-21+deb9u1 404 Not Found

I am doing a docker build on my MacBook Pro and it always keeps failing with following error:
Reading package lists...
Building dependency tree...
Reading state information...
Suggested packages:
zip
The following NEW packages will be installed:
unzip
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 170 kB of archives.
After this operation, 547 kB of additional disk space will be used.
Err:1 http://deb.debian.org/debian stretch/main amd64 unzip amd64 6.0-21+deb9u1
404 Not Found
E: Failed to fetch http://deb.debian.org/debian/pool/main/u/unzip/unzip_6.0-21+deb9u1_amd64.deb 404 Not Found
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get install unzip' returned a non-zero code: 100
docker version:
Docker version 19.03.8, build afacb8b
MacOS: Mojave 10.14.6
Dockerfile snippet:
FROM debian:latest
RUN apt-get update
RUN apt-get install -y ca-certificates
RUN apt-get install unzip
The build works fine in our travis CI which is using docker-ce=17.09.0~ce-0~ubuntu
Any suggestions on how to debug it further? Initially we thought it may be a temporary issue on debian side but the problem has persisted so likely an issue with my environment.
Combine the three RUN lines you show into a single command:
FROM debian:latest
RUN apt-get update \
&& apt-get install -y \
ca-certificates \
unzip
There's a combination of two things that leads to that 404 error. On the one hand, Docker will cache individual Dockerfile steps: it sees that, starting from debian:latest, it's already RUN apt-get update, so it uses the version of that command from yesterday. On the other hand, Debian updates their repositories fairly frequently with very minor updates (see the +deb9u1 part of that version number) and when they do they delete the previous version from their repositories. This combination means you can be in a sequence where you're using a cached version of the apt-get update index, but the package version it mentions doesn't exist any more.
Combining these lines together like this means Docker will always run both apt-get update and apt-get install together; if you add a package to the list it will re-run the update step before trying to download things. That avoids this problem, at the cost of a little extra download time when the package list changes.

Cannot retrieve latest version of Debian package inside Docker container

Inside a docker container (created from a node:9 image) I am trying to install stress-ng package using apt-get. However, for some reason an old version of the package is retrieved everytime I try to install it. For installing the package I use the commands:
root#7e7a683bf288:/usr/src/app# apt-get update
root#7e7a683bf288:/usr/src/app# apt-get install stress-ng
I get the following version:
root#7e7a683bf288:/usr/src/app# stress-ng --version
stress-ng, version 0.01.32
However, I would like to get the latest version if possible, 0.09.42-1 (https://packages.ubuntu.com/cosmic/stress-ng). I have tried some of the solutions in similar questions but was not able to get this to work.
Additional info:
root#7e7a683bf288:/usr/src/app# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root#7e7a683bf288:/usr/src/app# cat /etc/apt/sources.list
deb http://deb.debian.org/debian jessie main
deb http://security.debian.org/debian-security jessie/updates main
deb http://deb.debian.org/debian jessie-updates main
root#7e7a683bf288:/usr/src/app# add-apt-repository
bash: add-apt-repository: command not found
You have to add the unstable repo to your sources.list. When I did that, I still couldn't install stress-ng as it stated:
root#096865e3637f:/# apt-get install stress-ng
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libc6-dev : Breaks: binutils (< 2.26) but 2.25-5+deb8u1 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
So before installing I had to remove binutils.
Maybe that is an option for you.
The complete Dockerfile looks like:
FROM node:9
RUN echo "deb http://http.us.debian.org/debian unstable main non-free contrib" >> /etc/apt/sources.list && \
echo "deb-src http://http.us.debian.org/debian unstable main non-free contrib" >> /etc/apt/sources.list && \
apt-get remove binutils -y && \
apt-get update && \
apt-get install stress-ng -y
CMD stress-ng --version
stress-ng --version:
stress-ng, version 0.09.50 💻🔥
So, it is not 0.09.42, but the latest (unstable) version - as requested.

Error showing while trying to install Docker CE on Linux Ubuntu 18.04 Bionic?

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
docker-ce
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/33,8 MB of archives.
After this operation, 181 MB of additional disk space will be used.
(
Reading database ... 129600 files and directories currently installed.)
Preparing to unpack .../docker-ce_18.03.1~ce-0~ubuntu_amd64.deb ...
Unpacking docker-ce (18.03.1~ce-0~ubuntu) ...
dpkg: error processing archive /var/cache/apt/archives/docker-ce_18.03.1~ce-0~ubuntu_amd64.deb (--unpack):
trying to overwrite '/usr/bin/docker-containerd', which is also in package docker-containerd 0.2.3+git+docker1.13.1~ds1-1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/docker-ce_18.03.1~ce-0~ubuntu_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
I got this error when trying to install the latest Docker (v20.10.17) on Ubuntu Focal 20.04 (LTS) following the official documentation. I tried installing older versions and got the same error. When running sudo dockerd --debug it showed the real error:
failed to start daemon: Devices cgroup isn't mounted
Cgroupfs (Control Groups) are a kernel mechanism for tracking and imposing limits on resource usage on groups of tasks. So the solution is to mount it. Note that you need to stop the container daemon before mounting the cgroup and then start it again after that.
Stop daemon
sudo systemctl stop containerd
Unmount (just in case) and then mount the cgroup
sudo cgroupfs-umount
sudo cgroupfs-mount
Start the daemon again
sudo systemctl start containerd
sudo systemctl start docker.service
sudo systemctl start docker.socket
If there are errors still, re-install everything
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Test that Docker works
sudo docker run hello-world
I don't see 18.04 listed on the supported list so you may be encountering compatibility issues that the developers have not had time to resolve. To work around your immediate issue, I would uninstall "docker-containerd" and any other dependent packages since that appears to be based on a very old version of docker (1.13).
apt remove docker-containerd
Step 01 - Uninstall old version of Docker
$ sudo apt-get remove docker docker-engine docker.io containerd runc
$ sudo rm -rf /var/lib/docker
$ sudo apt-get autoclean
$ sudo apt-get update
Step 02 - Install Docker-ce:
Install a few prerequisite packages which let APT use packages over HTTPS:
$ sudo apt install apt-transport-https ca-certificates curl software-properties-common
Add the GPG key for the official Docker repository to system:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker repository to APT source:
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
Update the package database
$ sudo apt update
Make sure you are about to install from the Docker repo instead of the default Ubuntu repo
$ apt-cache policy docker-ce
Finally, install Docker:
$ sudo apt install docker-ce
Verify docker is running
$ sudo systemctl status docker

Installation of neo4j on ubuntu 14.04 fails

I am attempting to install neo4j in ubuntu 14.04 as specified in http://neo4j.com/docs/operations-manual/current/installation/linux/debian/?_ga=2.249168388.2041192375.1507250087-893468657.1507250087
The installation instruction I am using is
sudo apt-get install neo4j=3.2.3
but it doesn't work
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package neo4j
I'd apreciate any help
Maybe you forgot to add the debian repository and to update your list of packages:
wget -O - https://debian.neo4j.org/neotechnology.gpg.key | sudo apt-key add -
echo 'deb https://debian.neo4j.org/repo stable/' | sudo tee -a /etc/apt/sources.list.d/neo4j.list
sudo apt-get update
https://neo4j.com/docs/operations-manual/current/installation/linux/debian/#debian-add-repository
I had the same problem on Debian and installing "apt-transport-https" fixed it because deb https://debian.neo4j.org/repo stable/ is using https.
You can install it with this:
sudo apt install apt-transport-https

apt-get fails within container without sudo [closed]

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 5 months ago.
Improve this question
I have observed a problem where apt-get install will fail within a container where:
the package is already installed and,
sudo is not used.
This can be recreated by creating a simple container, e.g.
docker run -it ubuntu:latest /bin/bash
Within the container, run the following:
apt-get install software-properties-common
apt-get install software-properties-common
The second time, this will fail with a "Killed" message. If you then prepend the statement with sudo it will complete successfully:
sudo apt-get install software-properties-common
If the user within the container is root, why is sudo required to reinstall an existing package? I do not believe this is related to the AUFS file system as prepending with sudo will complete.
This is using docker 1.10 and an Ubuntu image.
The main point is the use of sudo
It doesn't fail on Debian 11:
# docker run -it ubuntu:latest /bin/bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
00f50047d606: Pull complete
Digest: sha256:20fa2d7bb4de7723f542be5923b06c4d704370f0390e4ae9e1c833c8785644c1
Status: Downloaded newer image for ubuntu:latest
# apt-get update
Hit:1 http://ports.ubuntu.com/ubuntu-ports jammy InRelease
Hit:2 http://ports.ubuntu.com/ubuntu-ports jammy-updates InRelease
Hit:3 http://ports.ubuntu.com/ubuntu-ports jammy-backports InRelease
Hit:4 http://ports.ubuntu.com/ubuntu-ports jammy-security InRelease
Reading package lists... Done
# apt-get install software-properties-common
Reading package lists... Done
...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Processing triggers for dbus (1.12.20-2ubuntu4) ...
# apt-get install software-properties-common
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
software-properties-common is already the newest version (0.99.22.3).
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
There may be something corrupt on your system. If running these don't help, you may need to reinstall:
apt-get update
apt-get upgrade
You need to install sudo package by following commands.
apt update && apt upgrade
apt install sudo

Resources