Home > OS >  What is the difference between Docker Unix socket on ubuntu vs alpine?
What is the difference between Docker Unix socket on ubuntu vs alpine?

Time:02-08

I am running through a problem where I can't mount Unix docker socket to an alpine container but works with ubuntu container.

docker-compose using alpine image

version: '3.8'

services:
  cluster:
    image:  alpine  
    tty: true  
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/usr/bin/docker:/usr/bin/docker"      

running docker command in the alpine container:

/ # docker --version
sh: docker: not found

docker-compose using ubuntu image

version: '3.8'

services:
  cluster:
    image:  ubuntu:20.04
    tty: true  
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/usr/bin/docker:/usr/bin/docker"      

running docker command in the ubuntu container:

root@5f30b4143c43:/# docker --version
Docker version 20.10.12, build e91ed57

I don't get why I can access my host docker env using the ubuntu container but not with the alpine one? is there anything missing in the configuration?

CodePudding user response:

Your error has nothing to do with the socket:

/ # docker --version
sh: docker: not found

You're seeing this because you're trying to run a binary compiled for glibc platform, while Alpine is built using MUSL libc.

You would need to install a version of the docker client built specifically for use under Alpine (or just pick almost any other image).

  •  Tags:  
  • Related