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

Unable to bind Docker running on VM to the container I am running #70

Closed
mavogel opened this issue Dec 25, 2020 · 1 comment
Closed
Labels
bug Something isn't working r/service Relates to the service resource stale

Comments

@mavogel
Copy link
Contributor

mavogel commented Dec 25, 2020

This issue was originally opened by @senthilmnathan as hashicorp/terraform-provider-docker#235. It was migrated here as a result of the community provider takeover from @kreuzwerker. The original body of the issue is below.



Hi All,

I am running a bunch of jenkins instances as docker services (hosted on 3 node Docker Swarm). I am using terraform to manage the configuration and state.
While everything is working fine, docker.sock wont bind from host to the container.

Terraform Version

Terraform v0.12.8

  • provider.docker v2.4.0

Affected Resource(s)

Custom Jenkins Docker Container is unable to bind with the host instance's docker service.

Terraform Configuration Files

main.tf

#This is the main script used by the project

resource "docker_service" "jenkins_service" {
  name = var.project_name
  task_spec {
    container_spec {
      image = docker_image.jenkins_image.name
      mounts {
        source = var.jenkins_volume
        target = "/var/jenkins_home"
        type   = "bind"
      }
      mounts {
        source = "/var/run/docker.sock"
        target = "/var/run/docker.sock"
        type   = "bind"
      }
    }
    networks = ["${docker_network.jenkins_network.name}"]
  }

  endpoint_spec {
    ports {
      target_port    = "8080"
      published_port = var.web_interface_port
      publish_mode   = "ingress"
      name           = "WEB_INTERFACE"
    }
    ports {
      target_port    = "50000"
      published_port = var.api_interface_port
      publish_mode   = "ingress"
      name           = "API_INTERFACE"
    }
  }
}

Expected Behavior

I should be able to run docker commands on the containers

Actual Behavior

I am unable to run docker command from within the docker container

-bash-4.2$ docker exec  -u 0 -it f1f1f38e9316 bash
root@f1f1f38e9316:/# su - jenkins
jenkins@f1f1f38e9316:~$ docker
-su: docker: command not found
jenkins@f1f1f38e9316:~$

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
  2. docker exec -u 0 -it <container_id> bash
  3. docker
@mavogel mavogel added bug Something isn't working r/service Relates to the service resource labels Dec 25, 2020
@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity.
Remove stale label or comment or this will be closed in 7 days.
If you don't want this issue to be closed, please set the label pinned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working r/service Relates to the service resource stale
Projects
None yet
Development

No branches or pull requests

1 participant