Docker command not found while docker.service is Active (running) - linux

I've installed docker on CentOS 7, but when I run docker, I get bash: docker: command not found...
Other apps that require docker gave this error: "docker": executable file not found in $PATH
which docker returns: no docker in (/usr/.....
whereis docker returns: docker: /etc/docker /usr/libexec/docker /usr/share/man/man1/docker.1.gz
This is how I installed it:
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
sudo yum update -y && sudo yum install -y \
containerd.io-1.2.13 \
docker-ce-19.03.11 \
docker-ce-cli-19.03.11
mkdir /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
]
}
EOF
sudo systemctl enable docker

I would recommend you to read the official documentation at docs.docker.com.
Did you successfully meet the OS requirements?
To install Docker Engine you need a maintained version of CentOS 7,
archived versions are not supported or tested.
The centos-extras repository must be activated. This repository is
activated by default, but if you deactivated it, you have to activate
it again.
The Overlay2 storage driver is recommended.
Have you deleted the older versions?
Older versions of Docker were called docker or docker-engine. If
these are installed, uninstall them, along with associated
dependencies.
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
I have sent you some document texts from the official Docker documentation page, I would recommend you to read the whole document page.

Related

GLIBC_2.27 not Found in Docker Container

I am now running a Docker container in my Linux machine. The dockerfile is as follows:
# 1. basic image
FROM tensorflow/tensorflow:1.12.0-devel-py3
ENV DEBIAN_FRONTEND=noninteractive LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_CTYPE="UTF-8"
# 2. apps
RUN apt update && apt install -y --no-install-recommends \
software-properties-common && \
add-apt-repository -y ppa:ubuntu-desktop/ubuntu-make && \
apt update \
&& apt install -y --no-install-recommends \
build-essential \
vim \
ubuntu-make \
&& umake ide pycharm /root/.local/share/umake/ide/pycharm
Everything goes on well, but when I enter the Docker container using the following command:
sudo docker run --ipc=host --gpus all --net=host -it -d --rm -h docker -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:rw
-v /usr/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu, -v /usr/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu
--privileged
Then I try command such as apt update, I will receive the following messages:
apt: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.27' not found (required by /usr/lib/x86_64-linux-gnu/libapt-pkg.so.5.0)
However, this will not happen if the command is invoked in the Docker image file Dockerfile. For example, at the end of the Dockerfile, if I invoke
RUN apt update && apt install -y firefox, no errors appear.
I cannot understand why only in the Docker container is GLIBC_2.27 link problem identified.
I got the answer thanks to the help of #KamilCuk.
The reason why I got this error is because my host machine is Ubuntu 18.04 and my guest machine (Container) is Ubuntu 16.04.
This is no problem, but when I enter the Container, I share the two folders between host machine and guest machine:
/usr/lib/x86_64-linux-gnu
/usr/lib/i386-linux-gnu
As a result, the guest system tries to use libraries in the host machine, which is wrong. I forgot the reason why I decide to share host machine's libraries with the guest machine. Anyway, if I disable it, everything goes on well.

How to install a PostgreSQL terminal client using microdnf install?

What PostgreSQL clients are available through microdnf install?
I'm trying to install a client via my Dockerfile.
I've tried multiple commands I've seen recommended and several guesses, but none of them worked for me:
microdnf install -y postgresql-client
microdnf install -y postgresql
microdnf install -y psql
etc.
Image being used:
https://hub.docker.com/r/jboss/keycloak/
sh-4.4$ cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="8.3 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.3"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.3 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8.3:GA"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.3
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.3"
PS = Is there a website I can go to to see the full list of packages available?
I have the same issue, but with maven docker image (it based on OracleLinux 8).
Oracle Linux 8 & Postgresql13 Client
It was extremely unusual to install postgresql client on it, so, let's consider my steps:
https://www.postgresql.org/download/linux/redhat/
Select RHEL 8 and receive the rpm package link
Install it manually with rpm
microdnf install -y wget
wget https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm -O /tmp/pg_repo.rpm
rpm -i /tmp/pg_repo.rpm
Determine that there is no postgresql13 package. Click on the direct download link and select RHEL 8: https://download.postgresql.org/pub/repos/yum/13/redhat/rhel-8-x86_64/
Download postgresql13-13.x.x... package (latest)
wget https://download.postgresql.org/pub/repos/yum/13/redhat/rhel-8-x86_64/postgresql13-13.3-2PGDG.rhel8.x86_64.rpm -O /tmp/pgql.rpm
Dependency list for that rpm:
libicu is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
libpq.so.5()(64bit) is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
postgresql13-libs(x86-64) = 13.3-2PGDG.rhel8 is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
systemd is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
systemd-sysv is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
Install dependencies
microdnf install -y systemd postgresql13-libs libicu
Finally, install the client
rpm -i /tmp/pgql.rpm
Now you can clear the cache and test the client, e.g. pg_dump command.
Result Dockerfile command:
RUN microdnf install -y wget && \
wget https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm -O /tmp/pg_repo.rpm && \
rpm -i /tmp/pg_repo.rpm && \
microdnf install -y systemd postgresql13-libs libicu && \
wget https://download.postgresql.org/pub/repos/yum/13/redhat/rhel-8-x86_64/postgresql13-13.3-2PGDG.rhel8.x86_64.rpm -O /tmp/pgql.rpm && \
rpm -i /tmp/pgql.rpm && \
rm -f /tmp/pg_repo.rpm /tmp/pgql.rpm && \
microdnf remove -y wget
RHEL 8 & Postgresql13 Client (your case)
Now let's consider your case, image jboss/keycloak:14.0.0 based on RHEL 8.
Caveat: If you receive error message error: Failed to create: /var/cache/yum/metadata, run as root user and than switch user back to jboss.
All steps and Dockerfile commands are the same.
Please, let me know if there are any mistakes or something is not well-described.
It's working for me on with a Dockerfile based on openjdk:15.
FROM openjdk:15.0.1-oracle
...
RUN microdnf update
RUN microdnf module enable postgresql:13
RUN microdnf install postgresql.x86_64

Docker run doesn't work as part of a terraform startup script

I'm using terraform to provision a bunch of machines at once. Each one should run the same docker container. The startup script looks like this:
sudo apt-get remove docker docker-engine docker.io containerd runc -Y
sudo apt-get update -Y
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common -Y
curl https://get.docker.com | sh && sudo systemctl --now enable docker
sudo docker build -t dockertest /path/to/dockerfile
sudo docker run --gpus all -it -v /path/to/mount:/usr/src/app dockertest script.py -b 03
Basically it installs docker and then builds the container and then runs it.
Only the last line doesn't work. If I ssh into the machine, it works fine. But not as part of the startup script.
How can I get it to work as part of the startup script? It's a hassle to ssh into each of a swarm of machines.
If anyone else encounters this problem: the solution is simply to take -it out of the docker run command.

Hyperledger Fabric 1.0 on CentOS Error endorsing chaincode?

I am running CentOS Linux release 7.2.1511 (Core).
Running the "first network" sample of the brand new Hyperledger Fabric 1.0 out yesterday I am getting the error:
Error: Error endorsing chaincode: rpc error: code = Unknown desc = Error starting container: API error (500): {"message":"oci runtime error: container_linux.go:262: starting container process caused \"process_linux.go:339: container init caused \\"read init-p: connection reset by peer\\"\"\n"}
How do I debug further?
My complete installation procedure of prereqs was as follows:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2 policycoreutils-python git dos2unux unzip gcc-c++ make
sudo yum-config-manager --enable rhel-7-server-extras-rpms
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.9-4.el7.noarch.rpm
yum -y install docker-ce
sudo yum -y install docker-ce
sudo systemctl start docker
sudo docker run hello-world
sudo usermod -aG docker root
sudo usermod -aG docker vagrant
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install -y ./epel-release-latest-7.noarch.rpm
sudo yum install -y python-pip
sudo pip install docker-compose
sudo yum upgrade python*
cd
mkdir docker-compose-hello-world
cd docker-compose-hello-world
echo 'my-test:' > ./docker-compose.yml
echo ' image: hello-world' >> ./docker-compose.yml
docker-compose up
sudo docker-compose up
cd
mkdir golang
cd golang
echo downloading go1.8.3.linux-amd64.tar.gz
wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
sudo cp ./go1.8.3.linux-amd64.tar.gz /usr/local
cd /usr/local
sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz
sudo vi /etc/profile
cd
sudo curl -sL https://rpm.nodesource.com/setup_6.x | sudo bash -
sudo yum install -y nodejs
sudo npm install npm#latest -g
cd
git clone https://github.com/hyperledger/fabric-samples.git
sudo docker run hello-world
sudo systemctl start docker
sudo docker run hello-world
cd fabric-samples
# Stackoverflow validation asked me to replace short URL
# goo.gl/iX9dek with long one below:
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap-1.0.0.sh | sudo bash
cd first-network
yes | sudo ./byfn.sh -m generate
yes | sudo ./byfn.sh -m up
My NodeJs (node) version is v6.11.1
My npm version is 5.2.0
My Golang version is go1.8.3 linux/amd64
Thanks in advance for any enlightenment!
Resolved!
Inspired by reference https://github.com/moby/moby/issues/34046, I upgraded the Linux kernel using the instructions at:
https://www.tecmint.com/install-upgrade-kernel-version-in-centos-7/
Works perfectly after a reboot and a selection of the new kernel in the boot menu.
Downside: the Vagrant shared folders between the Windows 7 host OS and the CentOS virtual machine no longer work, but that should be fixed by the next Oracle Virtualbox client tools update.

Installing Docker.io on Ubuntu 14.04LTS

I'm running a virtual machine in Windows Azure with the prebuild image for Ubuntu 14.04 LTS.
When I want to install Docker.io like described here:
http://blog.docker.io/2014/04/docker-in-ubuntu-ubuntu-in-docker/
The installation works but when i`m running:
sudo docker.io pull ubuntu
An error will be thrown:
Cannot connect to the Docker daemon. Is docker -d running on this host?
Can anyone help or has the similar problem?
P.S.: Can anyone with a high reputation create a Tag for Ubuntu-14.04?
Evidently the docker daemon is not running. You wanna check /etc/default/docker.conf for proper configuration and issue
sudo service docker.io start
or
sudo service docker start
depending on how they called the service
Adding myself to the docker group:
sudo usermod -a -G docker myuser
and rebooting the machine worked for me. This solution is discussed in: https://github.com/docker/docker/issues/5314
On Ubuntu 14.04, the docker.io package installs Docker 0.9.1.
According to the documentation, to install the current version use these commands:
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
$ sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
$ sudo apt-get update
$ sudo apt-get install lxc-docker
There is also a simple script available to help with this process:
$ curl -s https://get.docker.io/ubuntu/ | sudo sh
Alternatively, check the azure-docker-registry project for an example of how to automate Azure provisioning and Docker container deployment. For instance, this Ansible playbook:
- name: create docker data directory
file: path=/mnt/data/docker state=directory
- name: store docker files in data disk
file: src=/mnt/data/docker dest=/var/lib/docker state=link
- name: add repository key
command: creates=/etc/apt/sources.list.d/docker.list apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
- name: copy repository source file
copy: src=docker.list dest=/etc/apt/sources.list.d/docker.list
- name: install docker package
apt: name=lxc-docker update_cache=yes state=present
Also make sure to symlink the docker.io binary to docker to use the tutorials/documentation without rewriting every command.
ln -s /usr/bin/docker.io /usr/bin/docker
Run docker -d to see if it shows any error messages.
If apparmor is missing install it with sudo apt-get install apparmor
Then sudo service docker start
Hard to say but sometime official docker installation procedure fails on Ubuntu 14.04.
One can simply install docker using below given commands [Quick and Dirty]
sudo apt-get update
sudo apt-get -y install docker.io

Resources