Fail to run docker while building an image

前端 未结 3 1974
既然无缘
既然无缘 2021-01-22 02:54

I tried to install a software with Docker while building an image and I get.

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. 
Is the         


        
3条回答
  •  滥情空心
    2021-01-22 03:12

    Is there a way to run docker commands in a Dockerfile for creating images?

    No. You can’t run Docker commands from inside a Dockerfile.

    The usual approach to this is to share the host’s Docker socket with a container, but you can’t mount any volumes or host directories during an image build process. In principle you can run a secondary Docker inside a main Docker container (though this is discouraged, complicated, and fragile) but again since you can’t really start services inside a Dockerfile this won’t work.

    Given the sorts of things you’re trying to install in your image, it looks like you’re looking for some sort of system-level automation tool that can run directly on the host, not something that wants to run in a constrained container environment. Ansible, Salt Stack, and Chef are all popular options in this space.

提交回复
热议问题