1

I am using YAML file configuration as below mentioned, unable to create a folder and change access of dir. It is able to create the directory but unable to complete this command chmod 777 /opt/ldap

ldap:
image: osixia/openldap:1.3.0
env_file:
  - env/ldap.env
networks:
  appworks_net:
    aliases:
      - docker_container.local
restart: "no"
command: bash -c "mkdir -p /opt/ldap && chmod 777 /opt/ldap"  - **creates only folder**
command: ["/bin/bash", "-c", "mkdir -p /opt/ldap && chmod 777 /opt/ldap"] -- fails start container
command: ["-c", "chmod 777 /opt/ldap"] -- does not work
command: chmod 777 /opt/ldap -- does not work
command: ["-c", "mkdir -p /opt/appworks/ldap", "chmod 777 /opt/appworks/ldap"] -- only creates folder
command:
  - -c
  - |
    mkdir -p /opt/ldap
    chmod 777 /opt/ldap  -- **creates only folder**
healthcheck:
  test: ["CMD-SHELL", '/usr/bin/ldapsearch -h ldaps://$$HOSTNAME -p $$PORT -w $$LDAP_ADMIN_PASSWORD -D "cn=admin,dc=trialorg,dc=local" -b "dc=trialorg,dc=local" | grep "dn:"']
  interval: 5s
  timeout: 5s
  retries: 10

please help me here if there are any possible working ideas. I don't want to create a new image using a docker / entrypoint. I just that two commands to run post container is started.

Alexey Usharovski
  • 1,404
  • 13
  • 31
Vijay
  • 1,026
  • 3
  • 11
  • 28

1 Answers1

-1

What about

command:
  - -c
  - |
    mkdir -p /opt/ldap;
    chmod 777 /opt/ldap;

or

command:
  - -c
  - |
    mkdir -p /opt/ldap && chmod 777 /opt/ldap;

Also are you sure that you have UNIX line endings in your file?

Another possible solution Using Docker-Compose, how to execute multiple commands

Alexey Usharovski
  • 1,404
  • 13
  • 31
  • 1) it created a wrong folder as below root@da81f56f693a:/opt/# ls -lrt total 0 drwxr-xr-x 2 root root 6 Dec 19 03:52 'ldap;' 2) it created folder but not provided access root@da81f56f693a:/opt/appworks# ls -lrt total 0 these suggestions i already followed, not working too. drwxr-xr-x 2 root root 6 Dec 19 03:52 ldap drwxr-xr-x 2 root root 6 Dec 19 03:52 'ldap;' – Vijay Dec 19 '19 at 03:54