Docker plugins are not recognized as commands when running without sudo - linux

I'm running
Ubuntu 20.04.5 LTS
Docker version 23.0.1, build a5ee5b1
Running the command
docker build -t some:other Dockerfile
Produces the following output:
unknown shorthand flag: 't' in -t
And
docker build
The following:
docker: 'buildx' is not a docker command.
I installed Docker as recommended from the repo: instructions
Other plugins don't work either (docker compose is not recognized either). Even then, docker info shows
buildx: Docker Buildx (Docker Inc.)
Version: v0.10.2
Path: /home/jpartanen/.docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.16.0
Path: /home/jpartanen/.docker/cli-plugins/docker-compose
scan: Docker Scan (Docker Inc.)
Docker runs without sudo with the help of the docker user group, as explained in linux-postinstall. I want to run plugins without sudo as well.
I've reinstalled Docker and rebooted the machine without any change.
What could be the problem?

Make the plugins runnable for docker by creating a link:
ln -s /usr/libexec/docker/cli-plugins/ ~/.docker/cli-plugins
The command not being recognized by Docker is extra confusing because of the mismatch in commands, build vs buildx. This is because Docker Engine 23.0 set Buildx and BuildKit as the default builder on Linux. docker build is aliased to docker buildx build.
As for running without sudo, the problem is possibly caused by the plugins being installed in the wrong place. On my machine, running the command
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
installs the plugins in /usr/libexec/docker/cli-plugins/, whereas as laid out here, the plugins are usable from $HOME/.docker/cli-plugins (without sudoing).
A somewhat robust solution is to create a link as laid out above.

Related

Jenkins error buildind : docker: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by docker)

Jenkins job fails when entering docker build stage:
docker build -t jumperiz/nodeapp .
Error message:
docker: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by docker)
docker: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by docker)
A picture of my build attached. Any guidance would be appreciated!
Jenkins screenshot
I had the same problem, as described in detail here.
To upgrade libc version in the Jenkins container to 2.35 (as shipped with Ubuntu Jammy installed on the host) I had to build my own Jenkins container based on this system (ubuntu:jammy) and on JDK 17, using template from the official Debian-based one (sourced from here).
Now GLIBC versions agree, and Docker-in-Docker Jenkins builds can be made using Docker installed on any host with Ubuntu Jammy (but not newer Ubuntu versions, given that next in line, ubuntu:22.10 already has a newer version of glibc=2.36):
$ ldd --version
ldd (Ubuntu GLIBC 2.35-0ubuntu3.1) 2.35
# vs.
$ docker run --rm -it mirekphd/jenkins-jdk17-on-ubuntu2204:latest ldd --version
ldd (Ubuntu GLIBC 2.35-0ubuntu3.1) 2.35
Feel free to use this container maintained automatically for our internal use (it's a Docker-in-Docker Jenkins-made-by-Jenkins pipeline:)
You need to install docker manually and you can follow this steps:
run jenkins container on detached mode:
docker run -p 8080:8080 -p 50000:50000 -d -v /var/run/docker.sock:/var/run/docker.sock -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts
Enter the jenkins container as root user:
docker exec -it -u0 <container id> bash
Install docker:
curl https://get.docker.com > dockerinstall && chmod 777 dockerinstall && ./dockerinstall
And then exit the Jenkins container and change docker.sock privilege to read and write for all users with:
sudo chmod 666 /var/run/docker.sock

How do I install and configure Docker on Ubuntu-like systems (Kubuntu)

i tried using ddev with Linux Kubuntu and did as proceeded as described here:
https://t3terminal.com/typo3-tutorials/install-typo3-docker-ddev/
means:
// Install DDEV
curl -L https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh | bash
// Install mkcert
sudo apt install libnss3-tools
mkcert -install
// Check DDEV works well?
ddev
$ ddev config
… Project name (temp-test): test
… Docroot Location (current directory):
Found a php codebase at ~/github/temp-test.
… Project Type [backdrop, drupal6, drupal7, drupal8, drupal9, laravel, magento, magento2, php, shopware6, typo3, wordpress] (php): laravel
… You may now run 'ddev start'.
~/github/temp-test$ ddev start
Could not connect to docker. Please ensure Docker is installed and running.
So i found this tip's here: Docker can't connect to docker daemon :
~/github/temp-test$ sudo service docker stop && sudo service docker start
Warning: Stopping docker.service, but it can still be activated by:
docker.socket
~/github/temp-test$ ddev start
Could not connect to docker. Please ensure Docker is installed and running.
~/github/temp-test$ sudo service docker start
~/github/temp-test$ ddev start
Could not connect to docker. Please ensure Docker is installed and running.
~/github/temp-test$ sudo service docker restart
~/github/temp-test$
it looks as if docker is installed (because it talks to me Warning: Stopping docker.service) but ddev does not find docker. what else can try?
Docker version
~ docker --version
Docker version 20.10.8, build 3967b7d
Operating System
Kubuntu 20.04
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8
You need to install docker on Kubuntu to use it.
Details are in the [ddev docs].(https://ddev.readthedocs.io/en/stable/users/docker_installation/#linux-installation-docker-and-docker-compose)
But the bottom line is:
You're using the Ubuntu setup.
Use the instructions for Ubuntu 20.04 assuming you're using something 20.04+: sudo apt-get update && sudo apt-get install docker.io docker-compose
Make sure to do the post-install, which requires you to add your own user to the "docker" group. sudo usermod -aG docker $USER, details in the linked docker instructions

Run linux/arm container via qemu binfmt_misc on Docker LCOW

I release ARM binaries of my software, by running the compiler toolchain on an emulated ARM machine.
Linux can run foreign binaries by registering qemu-user-static in /proc/sys/fs/binfmt_misc/. This allows you to run an ARM32 or ARM64 Docker image on an x86_64 Docker host, as follows:
Preparation:
# Apply `binfmt_misc` changes on host OS
docker run --rm --privileged multiarch/qemu-user-static:register --reset
Dockerfile:
# Get x86_64 qemu-user-static binaries
FROM debian:buster
RUN apt-get update && apt-get install -qqy qemu-user-static
# Get cross-arch rootfs
FROM arm64v8/golang:latest
COPY --from=0 /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64-static
This works great on Docker for Linux.
It also works great on Docker for Windows when using Linux Containers (MobyLinuxVM)
It doesn't work when using Docker for Windows when using Windows Containers (LCOW / hcsdiag mode). I want to use this mode because it can run both Linux and Windows containers. But it's not possible to modify the binfmt_misc file via the --privileged flag:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: Windows does not support privileged mode.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.
Current (1803-era) versions of Hyper-V HCS run a real Linux kernel, not a WSL one. I guess it should be possible to modify the host's binfmt_misc directory.
How is it possible to run a Linux/ARM container image on a Windows/x86_64 Docker host running LCOW?
Is it possible to modify the Linux host image used by LCOW?
Is there any other way to get a unified docker daemon that is capable of running Windows/x86_64, Linux/x86_64 and Linux/ARM Docker images?

Running a Spring Boot app from Docker is not working

I have a rather strange problem. I am trying to run a Spring Boot app via docker. So here are my steps.
1) I am creating a Dockerfile.
FROM centos
RUN yum install -y java
VOLUME /tmp
ADD /spring-boot-web-0.0.1-SNAPSHOT.jar myapp.jar
RUN sh -c 'touch /myapp.jar'
ENTRYPOINT [“java","-Djava.security.egd=file:/dev/./urandom","-
jar","/myapp.jar"]
In this file I am installing java. I am also using the jar file of the app called spring-boot-web-0.0.1-SNAPSHOT.jar
2) The next step is to build an image. So I am typing
tmp theodosiostziomakas$ docker build -t spring-boot-docker .
So the image was built correctly.
3) Now I am running that image to generate a container. So
docker run -d -p 8080:8080 spring-boot-docker
You can see that a container is generated. But when I type
$ docker ps
the container_id is not visible and when I type localhost:8080 in the browser the app is not running at all. Why is this happening? Any ideas? How to fix it?
If the posted Dockerfile the file you are using then there is a wrong quote sign just before java:
FROM centos
RUN yum install -y java
VOLUME /tmp
ADD /spring-boot-web-0.0.1-SNAPSHOT.jar myapp.jar
RUN sh -c 'touch /myapp.jar'
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/myapp.jar"]

'service docker status' fails: invalid arguments

I'm having trouble installing docker inside docker.
Outer docker works just fine but inner docker behavior is doubtful. I've followed all steps in official tutorial but after installation when I call status it still shouts error:
$ > sudo service docker status
/etc/init.d/docker: invalid arguments
* could not access PID file for Docker
BTW starting service works fine:
$ > sudo service docker start
* Starting Docker: docker [ OK ]
But docker itself seems to be working properly. hello-world is working and all other experiment I'm doing are also working so far. But I'm not sure I won't stumble upon some other issue later on.
I tried using several OS combinations. For outer OS i used Centos 7 and LinuxMint 17.3 and inner OS ubuntu:14.04 and ubuntu:16.04 but result is always the same (so I'm guessing it has to do something with ubuntu).
Outer docker is running docker with --privileged flag.
So it looks like this:
[outer OS Centos 7] docker run -ti --privileged ubuntu:14.04 bash
[inner OS Ubuntu] sudo service docker status
Thanks for the help,
x3mSpeedy

Resources