Can't connect to docker from docker-compose

前端 未结 24 2035
说谎
说谎 2020-12-07 10:14

I installed docker-machine 0.1.0 and docker-compose 1.1.0 on Mac OS 10.8.5.
Docker-machine is running normally and able to connect by docker-machine ssh.



        
相关标签:
24条回答
  • 2020-12-07 10:58

    I know it's silly, but in my case I just tried with sudo and it worked like a charm.

    in your case, just try: $ sudo docker-compose up

    0 讨论(0)
  • 2020-12-07 10:58

    My setup has got two cases for this error:

    • __pycache__ files created by root user after I run integration tests inside container are inaccessible for docker (tells you original problem) and docker-compose (tells you about docker host ambiguously);
    • microk8s blocked my port until I stopped it.
    0 讨论(0)
  • 2020-12-07 11:00

    If you started docker using sudo , then you should run docker-compose up with sudo Like: sudo docker-compose up

    0 讨论(0)
  • 2020-12-07 11:02

    By default the docker daemon always runs as the root user, therefore you need to prepend sudo to your Docker command(s).

    If you don’t want to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

    To create the docker group and add your user:

    1. Create the docker group.

      $ sudo groupadd docker

    2. Add your user to the docker group.

      $ sudo usermod -aG docker $USER

    3. Log out and log back in so that your group membership is re-evaluated.

    4. Verify that you can docker commands without sudo.

      $ docker run hello-world

    This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

    The steps outlined above comes from the official Docker documentation.

    0 讨论(0)
  • 2020-12-07 11:03

    I solved the issue in Ubuntu 20.0.4 by

    sudo chmod 666 /var/run/docker.sock
    

    and then

    sudo service docker start && docker-compose up -d
    

    Ref.

    0 讨论(0)
  • 2020-12-07 11:04

    try this:

    sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

    0 讨论(0)
提交回复
热议问题