Disable autostart of docker-compose project

后端 未结 4 2113
青春惊慌失措
青春惊慌失措 2021-02-06 21:11

I have a docker-compose project using Docker for Mac that autostarts when I boot the computer.

I usually start the project with docker-compose up -d, but ev

4条回答
  •  名媛妹妹
    2021-02-06 21:44

    restart: no is default mode. There is line inside your docker-compose file with restart: no or restart: unless-stopped. It also means that when you boot your system, it (re)starts container(s) again as long as docker daemon. Details
    You need to change restart to no or on-failure, example:

    version: '2.1'
    services:
        backend:
            restart: on-failure
            build:
                args:
                    USER_ID: ${USER_ID}
                context: codebase/namp-backend
                dockerfile: Dockerfile.dev
            ports:
              - "5001:5001"
              - "5851:5851"
            volumes:
              - ./codebase/namp-backend:/codebase
            environment:
    

    Also docker-compose down for most cases, gives you the same result - do not start containers while (docker) system startup, except: containers will be deleted after this, not stopped.

提交回复
热议问题