docker-compose: define mount for bind mount and managed mount

前端 未结 4 976
醉酒成梦
醉酒成梦 2021-02-01 15:17

I\'m using docker-compose for defining my service. In docker, there are two concepts for docker volume. Firstly is about bind mount: mount on host storage.

4条回答
  •  执念已碎
    2021-02-01 15:28

    I know it's late to answer but I'm mostly writing this for the community.

    Answer:

    You only need to do it like this:

        volumes:
           - ./root/instantclient_12_2/ojdbc8.jar:/etc/kafka-connect/jars/ojdbc8.jar
           - type: bind
             source: $HOST/etc
             target: /kernel-etc
    

    Then, for running it in 'easy to debug mode' do it first with docker-compose up and when you made sure it was working fine put a ring on it by adding a -d at the end.

    Important Notes

    1-Make sure your docker-compose version is at least 3.2 and in my case, it is3.7. for updating and getting rid of the old version do as below:

    sudo apt-get remove docker-compose
    sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose
    sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
    

    Source: https://github.com/10up/wp-local-docker/issues/58#issuecomment-476786006

    2- Don't forget to rm your old container so you don't face weird port-related issues. heres how:

    docker container stop YOUR_CONTAINER_ID
    docker container rm YOUR_CONTAINER_ID
    

    Good luck.

提交回复
热议问题