Troubleshooting Docker-Compose Installation on CentOS 7: libz.so.1 Error

Hello everyone,

I’m facing an issue with setting up Docker on CentOS 7 and need some advice. Here are the steps I followed:

Docker Community Edition Installation

Added Docker CE repo:

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Installed Docker CE:

sudo yum install docker-ce

Started Docker:

sudo systemctl start docker

Docker-Compose Installation

Used curl to install Docker-Compose:

sudo curl -L “https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

After installation, when I check the version with docker-compose --version, I encounter the following error:

docker-compose: error while loading shared libraries: libz.so.1: failed to map segment from shared object

Here is the cat etc/fstab output

/root/images/tmpfile.bin /tmp ext4 rw,noexec,nosuid,nodev 0 0

I suspect this issue might be related to the /tmp directory being mounted with noexec.

Questions:

  1. Based on my setup, does the issue seem related to the /tmp folder’s noexec setting?
  2. If I change the directory from /tmp to /var/tmp, could it resolve the issue? Would there be any potential side effects?

Thanks, in advance.

It is a shared library issue, which could be possibly solved by installing the dependency, but Docker Compose v1 is not supported anymore. You should not even try to install it. Use the docker compose plugin for Docker Compose v2. It is the “docker-compose-plugin” package.

Follow the official documentation

Hi, Thanks for the recommendation. Am I facing due to using v1 version? Although on our different server, this command (docker-compose --version) worked fine.

I’m just saying since v1 is not supported, I wouldn’t spend much time on fixing it. If it i a missing dependency, it is not hard to imagine that it exists on another machine. Compose v2 supports the old compose files and will ignore the version keyword. The difference is that you would use docker compose commands not docker-compose commands.

Hi @rimelek , i just checked the machine. The dependency also exist on this as well.

  1. Does the issue seem related to the /tmp folder’s noexec setting?
  2. If I change the directory from /tmp to /var/tmp, could it resolve the issue? Would there be any potential side effects?

I wanted to say no and I still don’t understand why it would be, but according to stack overflow, it does.

Where would you change it? I don’t see why you would mount the tmp to a different folder. If you don’t need the mount, don’t mount it. But I still think you should use Docker Compose v2.

After some investigation for noexec , I suspect this might be related to the noexec option set on my /tmp directory (Docker-compose needs to load some shared libraries from /tmp). Here’s the relevant output from cat /etc/fstab:

tmpfs                   /dev/shm                tmpfs   nodev,nosuid,noexec             0 0
/root/images/tmpfile.bin   /tmp   ext4    rw,noexec,nosuid,nodev    0 0
/tmp /var/tmp none rw,noexec,nosuid,nodev,bind 0 0

I have another server which have this out for cat etc/fstab

/dev/mapper/centos-root /                       xfs     defaults        1 1
UUID=6fd8c651-0add-48e8-a83d-454eb2241b26 /boot                   xfs     defaults        1 2
/dev/mapper/centos-home /home                   xfs     defaults        1 2
/dev/mapper/centos-swap swap                    swap    defaults        0 0

On this server docker-compose --version worked fine

I tried following and now docker-compose is working now.

Created new directory for docker-compose tmp files.

Then set this in ~/.bash_profile.

alias docker-compose="TMPDIR=/var/var/tmp docker-compose"

Now all related docker-compose commands are working as expected.