Docker Community Forums

Share and learn in the Docker community.

Running docker-compose inside a container

I am trying to build an image with docker-compose in it. I follow the instruction from this post: https://github.com/docker/compose/issues/3918

but when I run docker-compose in a shell of the container I get this error:

/bin/sh: docker-compose: not found

I added a comment to the post but since it is closed I suspect that nobody will notice… :frowning: So I am reposting it here:

My dockerfile (simplified to the point it is the same as in the post I referenced, except for the presence of python, which my app will use):

FROM python:3-alpine

COPY --from=library/docker:latest /usr/local/bin/docker /usr/bin/docker
COPY --from=docker/compose:1.23.2 /usr/local/bin/docker-compose /usr/bin/docker-compose

ENTRYPOINT [ “/bin/sh” ]

I guess I am missing something so I ran ldd on docker-compose:

/ # ldd /usr/bin/docker-compose
/lib64/ld-linux-x86-64.so.2 (0x7fef661d5000)
libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7fef661d5000)
libz.so.1 => /lib/libz.so.1 (0x7fef661bb000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fef661d5000)
Error relocating /usr/bin/docker-compose: __strcat_chk: symbol not found
Error relocating /usr/bin/docker-compose: __snprintf_chk: symbol not found
Error relocating /usr/bin/docker-compose: __vfprintf_chk: symbol not found
Error relocating /usr/bin/docker-compose: __stpcpy_chk: symbol not found
Error relocating /usr/bin/docker-compose: __vsnprintf_chk: symbol not found
Error relocating /usr/bin/docker-compose: __strncpy_chk: symbol not found
Error relocating /usr/bin/docker-compose: __strcpy_chk: symbol not found
Error relocating /usr/bin/docker-compose: __fprintf_chk: symbol not found
Error relocating /usr/bin/docker-compose: __strncat_chk: symbol not found

When running natively on the same host where the container is running (so the exact same kernel), ldd shows that the kernel injected linux-vdso.so.1

ldd /usr/local/bin/docker-compose
linux-vdso.so.1 => (0x00007ffdf5f83000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9023aaf000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f9023895000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f90234cb000)
/lib64/ld-linux-x86-64.so.2 (0x00007f9023cb3000)

but otherwise the same libraries are used.

Any idea what is going on?

export $PATH
:slight_smile:

Actually, the issue was something else; docker-compose is compiled against glibc. Alpine uses musl, not glibc… The post is was referring to probably never tested what was posted.