Reputation: 33
I'm trying to build a docker image inside an aspnetcore docker container. The aspnetcore container is a website which collects data from different sources and then dynamically builds a dockerfile. Afterwards I want to create a docker image from the dockerfile inside this aspnetcore application.
I tried to mount the docker socket in different ways but I cannot use the docker commands inside my container.
I refered to the following link: http://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/
so i tried to run the image and mount the docker socket in following ways:
directly in the cmd:
docker run -v /var/run/docker.sock:/var/run/docker.sock webinterface
inside my docker-compose file:
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
and then I tried to use the docker commands inside the container with:
docker exec -it webinterface bash
but the webinterface does not recognize any docker commands:
root@f3e434254601:/app# docker help
bash: docker: command not found
I also tried to use the docker remote API to execute commands by installing the nuget package "Docker.DotNet" and connect to the docker host as described in the offical documentation:
DockerClient client2 = new DockerClientConfiguration(new Uri("npipe:////./pipe/docker_engine"))
.CreateClient();
return await client2.Containers.ListContainersAsync(
new ContainersListParameters()
{
Limit = 10,
});
I'm totally lost... Does anyone have an idea? thank you!
Upvotes: 2
Views: 2389
Reputation: 1
If you want to execute docker commands you will still need to install docker.io
in your container (here called "webinterface").
Add this to the Dockerfile of your container-image.
Upvotes: 0