Skip to content

Add use_internal_docker_network feature#283

Closed
AaronKalair wants to merge 1 commit intotest-kitchen:masterfrom
AaronKalair:use-internal-docker-network
Closed

Add use_internal_docker_network feature#283
AaronKalair wants to merge 1 commit intotest-kitchen:masterfrom
AaronKalair:use-internal-docker-network

Conversation

@AaronKalair
Copy link
Copy Markdown

Hello,

I've been trying to use kitchen-docker from within another Docker container but by default it tries to SSH into localhost and use the mapped port which doesn't work from within a Docker container.

This patch adds an option called use_internal_docker_network which if set to true switches the port to 22 rather than the port that its mapped to on the host, and uses the IP of the container rather than localhost, enabling kitchen-docker to SSH into the container and run chef from within another Docker container.

kitchen-docker from inside a Docker container. If set switches the SSH
port to 22 and the hostname to the IP of the container so you can SSH
into the container from within another Docker container
@awiddersheim
Copy link
Copy Markdown

This looks like a good fix for #215. Can we get this merged?

@awiddersheim
Copy link
Copy Markdown

@AaronKalair I have noticed that on some platforms I'll get the following:

D      ---Nested Exception---
D      Class: Kitchen::ActionFailed
D      Message: Failed to complete #create action: [newline at the end of hostname]
D      ----------------------

Simple fix was to just modify things slightly:

      def container_ip(state)
        begin
          cmd = "inspect --format '{{ .NetworkSettings.IPAddress }}'"
          cmd << " #{state[:container_id]}"
          docker_command(cmd).strip # strip new lines here
        rescue
          raise ActionFailed,
          'Error getting internal IP of Docker container'
        end
      end

@matt9949
Copy link
Copy Markdown

matt9949 commented Feb 8, 2018

Would be great to get a fix to this problem merged.

There is another PR attempting to deal with this problem - #203

Without this fix, 'docker-in-docker' CI is not possible which is a shame as it would be an ideal solution for ansible CI.

@renaudhager
Copy link
Copy Markdown

We really need this, to allow a flawless CI pipeline.

This issue #215 has been opened 18 months ago :-(

@geez
Copy link
Copy Markdown

geez commented Feb 8, 2018

Same boat here, this PR would help our unit testing automation!

@mrjgreen
Copy link
Copy Markdown

It would be great to get this merged, having CI build and test our chef-config inside docker would be amazing. Please let us know what can be done to help get this into master.

@joshuatalb
Copy link
Copy Markdown

Any updates on this? It would greatly simplify our CI builds. Happy to help on getting this pushed through.

@bushelofsilicon
Copy link
Copy Markdown

I would also like to see this

@joshuatalb
Copy link
Copy Markdown

I ended up forking the edited code, cloning it locally and building my own Gem. If I have time this week, I'll try to fix the Travis tests so we can get this merged back into master.

@daleki
Copy link
Copy Markdown

daleki commented Jun 14, 2018

At the end of the Travis output I see these errors:
STDERR: failed to update store for object type *libnetwork.endpointCnt: Key not found in store

See this issue moby/moby#18113 for details. It seems like some versions of docker can get in a bad state? A work around for the failing build might be to delete /var/lib/docker/network/files/local-kv.db.

@amalucelli
Copy link
Copy Markdown
Contributor

I forked this PR into master, made the changes suggested, and opened the #304, the build is also passing now.

@tas50
Copy link
Copy Markdown
Member

tas50 commented Jan 18, 2019

This same functionality has been merged in #304.

@tas50 tas50 closed this Jan 18, 2019
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

Successfully merging this pull request may close these issues.