Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting back to the docker host #69

Open
jameslewis4891 opened this issue Aug 18, 2020 · 0 comments
Open

Connecting back to the docker host #69

jameslewis4891 opened this issue Aug 18, 2020 · 0 comments

Comments

@jameslewis4891
Copy link

When I receive a request to ask if a container can be started I would like to go back to the docker host and get the sha256 of the image thats being started. However I am getting errors indicating the plugin cannot talk to /var/run/docker.sock

I have the following code just trying to list the containers at present

func getContainers() {
	fmt.Printf("***** Container List\n")
	cli, err := client.NewClientWithOpts(client.FromEnv)
	if err != nil {
		panic(err)
	}

	containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
	if err != nil {
		panic(err)
	}

	for _, container := range containers {
		fmt.Printf("%s %s\n", container.ID[:10], container.Image)
	}
}

When running my container before creating the plugin I can achieve the desired behaviour by running the container as follows

docker run -v /var/run/docker.sock:/var/run/docker.sock ${TEMPLATE}:${VERSION}

I believe there is some config somewhere in the config.json to achieve the same thing but I cannot seem to do it I have tried

    "PropagatedMount": "/var/run/docker.sock",
    "Mounts": [
      {
          "Type": "bind",
          "Source": "/var/run/docker.sock",
          "Destination": "/var/run/docker.sock",
          "Mode": "",
          "RW": true,
          "Propagation": "rprivate"
      }
  ]

Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant