dockerfiles: libapparmor.so.1: cannot open shared object file: No such file or directory

Not sure if this rates as a samba, docker, or ubuntu issue, but:

# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
2c93025ecbcf        ubuntu:latest       /bin/bash           11 seconds ago      Up 11 seconds                           grave_sammet     
# docker run --rm -v $(which docker):/docker -v /var/run/docker.sock:/docker.sock svendowideit/samba grave_sammet
/docker: error while loading shared libraries: libapparmor.so.1: cannot open shared object file: No such file or directory

Yet apparmor does exist:

# ldconfig -v|grep apparmor
    libapparmor.so.1 -> libapparmor.so.1.1.0

Running on Ubuntu server 14.04.

About this issue

  • Original URL
  • State: open
  • Created 10 years ago
  • Comments: 29

Most upvoted comments

I believe the generic solution to this (docker-from-docker) is to install the Docker binary in the Dockerfile for your container with curl -fsSL https://get.docker.com/ | sh (or by other means). Don’t start the Docker service in the container.

Or use the API client libs in your tests/code as @cdancy suggested. Although IMO for simple use cases learning a new library could be overkill.

Then mount the socket but not the docker binary from the host when running the container.

@cdancy I think the point is that we want to enable apps, scripts, etc to use docker without reinventing the wheel. A good example of this is a build server agent. The agent can be built from a dockerfile, and anything running inside should be able to use docker commands the way they are used natively.

Docker remote api is still very cool, and enables interesting remote management solutions. I’m not trying to discredit that.

@MichaelMackus just install lxc on the actual docker container.

I found a workaround (but the fix is specific to Ubuntu 15.04). I can get my docker commands working if I bind-mount the missing library using -v /lib/x86_64-linux-gnu/libapparmor.so.1:/lib/x86_64-linux-gnu/libapparmor.so.1. Example:

$ docker run --rm -it \
-v /:/h \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker \
-v /lib/x86_64-linux-gnu/libapparmor.so.1:/lib/x86_64-linux-gnu/libapparmor.so.1 \
ubuntu docker --version

> Docker version 1.8.1, build d12ea79

(The host location of the libapparmor.so will vary depending on the host OS, Ubuntu 15.04 is different from 14.04 for example). On 14.04 use -v /usr/lib/x86_64-linux-gnu/libapparmor.so.1.1.0:/lib/x86_64-linux-gnu/libapparmor.so.1

FYI, the recommended way to do it today is to use the jpetazzo/dind if you need a base image. Otherwise @JosephEarl has the correct answer. Suggesting to close this issue before I feel the need to ask why people want to forward docker.sock/docker binary to the samba docker container? 😃