can not install docker in Ubuntu 16.04 - docker

I have installed ubuntu minimal in my virtual box (Ubuntu 16.04 LTS "Xenial Xerus")
I tried to install docker as follow:
apt-get update
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - && apt-key fingerprint 0EBFCD88
dpkg -S add-apt-repository && add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io
curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -
s)-$(uname -m)" -o /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose
but I have an error in this line
apt-get install -y docker-ce docker-ce-cli containerd.io
the error is:

I think you use the older docker commands for Ubuntu.
Try this:
If you have Docker already installed with apt-get - uninstall it.
sudo apt remove docker docker-engine docker.io
You need additional packages to allow apt use HTTP repositories. You can have them installed already, but run following to make it clear.
sudo apt install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
next
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add docker repository to your /etc/apt/source.list
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
next
sudo apt update
and finally
sudo apt install docker-ce

Related

Installing Docker on Debian image ends up with a huge image

I'm baking a Debian Docker image with Docker installed. When I follow the official instructions on installing Docker on Debian I end up with an 871MB size image. The official Docker image (built on Alpine) is closer to around 60-70MB. I don't understand why using Debian would need hundreds of additional MB.
Any ideas on how I can reduce the image size? Below is my Dockerfile.
FROM debian:buster-slim
RUN apt-get update \
&& apt-get install -y \
curl \
gnupg-agent \
software-properties-common \
lsb-release \
&& curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - \
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" \
&& apt-get update \
&& apt-get install -y docker-ce docker-ce-cli containerd.io \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

apt-get error: Version '5:19.03.4~3-0~ubuntu-bionic' for 'docker-ce' was not found

Documentation
provides syntax to install specific version of docker-ce:
$ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
On similar line, below dockerfile uses the above syntax:
FROM jenkins/jenkins:lts
ENV DEBIAN_FRONTEND=noninteractive
USER root
ARG DOCKER_GID=497
# Create Docker Group with GID
# Set default value of 497 if DOCKER_GID set to blank string by Docker compose
RUN groupadd -g ${DOCKER_GID:-497} docker
# Install base packages for docker, docker-compose & ansible
# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA8E81B4331F7F50 && \
RUN apt-get update -y && \
apt-get -y install bc \
gawk \
libffi-dev \
musl-dev \
apt-transport-https \
curl \
python3 \
python3-dev \
python3-setuptools \
gcc \
make \
libssl-dev \
python3-pip
# Used at build time but not runtime
ARG DOCKER_VERSION=5:19.03.4~3-0~ubuntu-bionic
# Install the latest Docker CE binaries and add user `jenkins` to the docker group
RUN apt-get update && \
apt-get -y install apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common && \
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) \
stable" && \
apt-get update && \
apt-get -y install docker-ce=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic} \
docker-ce-cli=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic} \
containerd.io && \
usermod -aG docker jenkins
ARG DOCKER_COMPOSE=1.24.1
# Install docker compose
RUN curl -L "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE:-1.24.1}/docker-compose-$(uname -s)-$(uname -m)" \
-o /usr/local/bin/docker-compose && \
chmod +x /usr/local/bin/docker-compose
RUN pip3 install ansible boto3
# Change to jenkins user
USER jenkins
# Add jenkins plugin
COPY plugins.txt /usr/share/jenkins/plugins.txt
RUN /usr/local/bin/plugins.sh /usr/share/jenkins/plugins.txt
fails at line below(on build):
apt-get -y install docker-ce=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic} \
docker-ce-cli=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic} \
containerd.io && \
where default values are retrieved from command: apt-cache madison docker-ce | awk 'NR==1{print $3}' in my local docker host
where docker-compose build gives below error:
Reading state information...
E: Version '5:19.03.4~3-0~ubuntu-bionic' for 'docker-ce' was not found
E: Version '5:19.03.4~3-0~ubuntu-bionic' for 'docker-ce-cli' was not found
ERROR: Service 'jenkins' failed to build: The command '/bin/sh -c apt-get update && apt-get -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common && curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable" && apt-get update && apt-get -y install docker-ce=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic} docker-ce-cli=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic} containerd.io && usermod -aG docker jenkins' returned a non-zero code: 100
apt-get -y install docker-ce docker-ce-cli containerd.io is able to download and install the latest version of ubuntu packages, but why download and install of specific version of ubuntu package fails?
apt-get -y install docker-ce=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic} \
docker-ce-cli=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic} \
containerd.io && \
You've selected Docker versions based on what's available on your build host, not what's available inside the container image you're building. The jenkins:lts image is based on Debian Stretch, not Ubuntu Bionic.
Dockerfiles are actually just running fairly ordinary Docker operations. So, for example, you can run docker run -ti -u root jenkins/jenkins:lts /bin/bash, run your RUN scripts by hand, and check the apt-cache output inside the container:
# apt-cache madison docker-ce
docker-ce | 5:19.03.4~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
docker-ce | 5:19.03.3~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
docker-ce | 5:19.03.2~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
docker-ce | 5:19.03.1~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
docker-ce | 5:19.03.0~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
Also, a failed docker build should leave the partially-complete image around; so you can use that directly to investigate a failure. As an example with a trivially failing step RUN false:
⋮
Removing intermediate container baaeab34bb8c
---> 6d34bab07796
Step 3/3 : RUN false
---> Running in 8347f442dfaa
The command '/bin/sh -c false' returned a non-zero code: 1
The 6d34bab07796 image is left around. You can pass that to docker run and investigate why the command failed. The 8347f442dfaa container is also left around, though exited; you can use the various docker container subcommands to investigate it as well.

i can't install docker on ubuntu 17.10

i'am trying to install Docker on my ubuntu 17.10 so i followed the instructions on the link :
https://docs.docker.com/install/linux/docker-ce/ubuntu/
sudo apt-get update
it shows
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
shows
what can i do please ?
I had similar issues installing Docker on a Ubuntu VM. This is what worked for me.
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce
And finally sudo systemctl status docker to check if it has installed properly.
symlinking the https dir in /usrLib/apt/methods to http seems to work:
$ cd /usr/lib/apt/methods
$ ln -s http https
Make sure you dont have any sources with https:// configured after apt-get install apt-transport-https it actually overwrites the symlink with the correct files.
After that run the docker installation script:
# remove old packages
$ sudo apt-get remove docker docker-engine docker.io containerd runc
# update
$ sudo apt-get update
# install dependencies
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
# fetch rep
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# add stable repo
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# update
$ sudo apt-get update
# install
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
This should work (from official docs)

Docker in docker on Windows 10

I have a Ubuntu18.04 server and want to run docker in it to launch containers.
Because I have Windows locally, I planned to use Docker to launch the Ubuntu18.04 server itself. But there seems to be some problem with runlevels on Windows:
invoke-rc.d: could not determine current runlevel
This problem is already known, but without any answer yet.
I tried the following Dockerfile:
FROM ubuntu:18.04
ARG WORK_DIR="myapp"
WORKDIR ${WORK_DIR}
# some basic programs
RUN apt update && apt install -y \
zsh \
wget \
curl \
git-core \
vim \
emacs
#install docker
# https://answers.microsoft.com/en-us/windows/forum/windows_10-windows_install/errors-in-ubuntu-1804-on-windows-10/fe349f3d-3d58-4d90-9f8f-c14d7c12af8b
RUN cp -p /bin/true /sbin/ebtables \
&& apt update -y \
&& apt upgrade -y \
apt update \
&& apt install -y apt-transport-https ca-certificates curl software-properties-common \
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" \
&& apt update \
&& apt-cache policy docker-ce \
&& echo exit 0 > /usr/sbin/policy-rc.d \
&& export RUNLEVEL=1 && apt install -y docker-ce
RUN docker run hello-world
The apt install -y docker-ce raises the error.

Docker Image with Lando Support

I am trying to build a Docker image where Lando should be preinstalled.
My Dockerfile looks like :
FROM devwithlando/php:7.1-fpm
RUN apt-get update -y \
&& docker-php-ext-install pcntl
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
RUN apt-get update
RUN apt-get install -y docker-ce
#RUN usermod -aG docker ${USER}
RUN apt-get update
RUN curl -fsSL -o /tmp/lando-latest.deb http://installer.kalabox.io/lando-latest-dev.deb
RUN dpkg -i /tmp/lando-latest.deb
RUN lando version
But It's showing "lando command not found", Is anything I am missing, Please guide me.
Lando has essentially 3 dependencies:
Docker (Docker CE on Linux)
Docker-Compose
NodeJS (Typically the current LTS)
A container trying to run Lando itself should probably run from the [Docker][1] image, with all the typical "Docker in Docker" modifications and caveats such is possibly mounting the docker socket in the container, and running privileged mode, etc.
Your example is running from Lando's PHP FPM base image, which isn't at all designed to run either Docker or Node. It also isn't based on Ubuntu, but rather Debian directly (and you are including some Ubuntu specific code for installing Docker).
All that said, running Lando from within a Docker container is likely to run into issues with permissions and volume mounts among potential other things. It isn't recommended, though it might be possible.
Here is a Dockerfile from a small repo I made a few years back that worked to install an old version of Lando in a Dockerfile, it could help you make a more up to date one:
FROM ubuntu:bionic
RUN mkdir -p /root/.bin && touch /root/.zshrc
RUN apt update && apt upgrade -y && apt install -y \
git \
exuberant-ctags \
neovim \
python3-pip \
software-properties-common \
wget \
zsh
RUN chsh -s $(which zsh)
RUN add-apt-repository ppa:martin-frost/thoughtbot-rcm \
&& apt update \
&& apt install rcm -y
RUN git clone https://github.com/thinktandem/dotfiles.git ~/dotfiles \
&& mkdir -p ${XDG_CONFIG_HOME:=$HOME/.config} \
&& mkdir -p $XDG_CONFIG_HOME/nvim \
&& ln -s ~/.vim/autoload ~/.config/nvim/ \
&& ln -s ~/.vimrc $XDG_CONFIG_HOME/nvim/init.vim \
&& rcup
RUN git clone https://github.com/nodenv/nodenv.git ~/.nodenv
RUN git clone \
https://github.com/nodenv/node-build.git \
/root/.nodenv/plugins/node-build
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt remove cmdtest \
&& apt update \
&& apt install --no-install-recommends yarn -y
RUN add-apt-repository ppa:cpick/hub \
&& apt update \
&& apt install -y hub
RUN apt remove docker docker-engine docker.io \
&& apt install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
| apt-key add - \
&& add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
bionic \
stable" \
&& apt update \
&& apt install -y docker-ce
RUN TEMP_DEB="$(mktemp)" \
&& wget -O "$TEMP_DEB" \
'https://github.com/lando/lando/releases/download/v3.0.0-rc.1/lando- v3.0.0-rc.1.deb' \
&& dpkg -i "$TEMP_DEB" \
&& rm -f "$TEMP_DEB"
RUN curl -L git.io/antigen > ~/antigen.zsh
RUN RCRC=$HOME/dotfiles/rcrc rcup
CMD ["/usr/bin/zsh"]

Resources