如何在AspNetCore网站Docker-Container中使用Docker命令?

我正在尝试在一个aspnetcore docker容器内build立一个docker镜像。 aspnetcore容器是一个网站,从不同的来源收集数据,然后dynamicbuild立一个dockerfile。 之后我想在这个aspnetcore应用程序里面的dockerfile中创build一个docker镜像。

我试图以不同的方式安装docker套接字,但我不能在我的容器中使用docker命令。

我提到以下链接: http : //jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/

所以我试图运行该图像和以下列方式安装dockersockets:

直接在cmd中:

docker run -v /var/run/docker.sock:/var/run/docker.sock webinterface 

在我的docker-compose文件里面:

 services: webinterface: image: webinterface container_name: webinterface build: context: ./WebInterface dockerfile: Dockerfile external_links: - geonode_geonode_1 ports: - "5000:80" volumes: - /var/run/docker.sock:/var/run/docker.sock 

然后我尝试在容器内使用docker命令:

 docker exec -it webinterface bash 

但web界面不能识别任何docker命令:

 root@f3e434254601:/app# docker help bash: docker: command not found 

我还试图通过安装nuget软件包“Docker.DotNet”来使用docker remote API来执行命令,并按官方文档中所述连接到docker主机:

  DockerClient client2 = new DockerClientConfiguration(new Uri("npipe:////./pipe/docker_engine")) .CreateClient(); return await client2.Containers.ListContainersAsync( new ContainersListParameters() { Limit = 10, }); 

我完全失去了…有没有人有一个想法? 谢谢!