Sunday, January 21, 2018

Docker - Convert docker-compose to docker run

There are not many good posts about how to convert a docker-compose file to "docker run" commnad. So I decide to provide an exmaple:

Docker Compose file:
version: "2"
services:
  openldap:
    image: osixia/openldap:latest
    ports:
      - "389:389"
    environment:
      - hostname=openldap
      - LDAP_ORGANISATION=lixu
      - LDAP_DOMAIN=lixu.ca
      - LDAP_ADMIN_PASSWORD=password
      - loglevel=debug
    volumes:
      - ./ldap:/var/lib/ldap
      - ./etc:/etc/ldap/slapd.d
      - ./scripts:/etc/ldap/scripts

Docker run command:
$ docker run -p 389:389 osixia/openldap:latest -v ./ldap:/var/lib/ldap \
    -v ./etc:/etc/ldap/slapd.d -e hostname=openldap -e LDAP_ORGANISATION=lixu \
    -e LDAP_DOMAIN=lixu.ca -e LDAP_ADMIN_PASSWORD=password --loglevel=DEBUG

For "docker run" parameter list:
https://docs.docker.com/engine/reference/commandline/run/#options

No comments: