0

I've encountered an issue with Docker on CentOS 7. Although I have successfully installed both Docker and Docker-Compose, when I run docker-compose --version, I receive the following error:

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

After some investigation, 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 need advice on how to resolve this. Should I modify the fstab settings for the /tmp directory, or is there another solution? Thank you for your help!

I am using CENTOS7

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

New contributor
adnan is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
5
  • 2
    CentOS 7 is based on 10 year old technology and will reach End of Support in 6 months. You probably shouldn't do any new development on your existing CentOS 7 server. -|- Note that most Linux applications wil honour the TMPDIR environment variable and you can also use that instruct docker and docker-compose to use a different directory for temporary storage, i.e. use your existing /var/tmp/ or make a new directory mkdir -p /data/tmp ; export TMPDIR=/data/tmp and then run your Docker commands.
    – HBruijn
    Nov 30 at 10:42
  • Thanks for the suggestion and reply @HBruijn. export TMPDIR=/data/tmp Is this for current session only or will it be permanent?
    – adnan
    Nov 30 at 10:45
  • 1
    Environment variables set on the command line exist only for the lifetime of that session (simplified until you log out) You make an environment persistent by ensuring that it gets set whenever you need it (for example by setting it in a ~/.bashrc , including it in a systemd service unit, adjusting a start-up script etc. etc.
    – HBruijn
    Nov 30 at 10:50
  • Thanks for clarifying info. Can I use this command If I want to specifically define tmp directory for docker-compose command only in bashrc ? alias docker-compose="TMPDIR=${HOME}/tmp docker-compose"
    – adnan
    Nov 30 at 11:06
  • 1
    Yes. Just try if that works for you.
    – HBruijn
    Nov 30 at 13:14

1 Answer 1

0

Based on Hbruijn comments. 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.

New contributor
adnan is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .