kitchen-docker icon indicating copy to clipboard operation
kitchen-docker copied to clipboard

Cannot use docker transport when using docker tmpfs on /tmp

Open RulerOf opened this issue 4 years ago • 0 comments

:ghost: Brief Description

When using a run_option to specify /tmp as a tmpfs, using the docker transport fails. This configuration is necessary to implement the recommended way to run systemd in a container.

Version

  • kitchen-docker (2.11.0)

Environment

Mac OS with Docker Desktop 4.2.0

Scenario

The docker transport attempts to copy a shell script to /tmp inside of the container, but when it's declared as a tmpfs, this can silently fail.

Steps to Reproduce

This .kitchen.yml should do it:

---
driver:
  name: docker
  # Required by Systemd
  run_options:
    env: container=docker
    stop-signal: SIGRTMIN+3
    tmpfs:
      - /tmp
      - /run
  volume:
    - /sys/fs/cgroup:/sys/fs/cgroup:ro

transport:
  name: docker

provisioner:
  name: dummy

platforms:
  - name: oraclelinux-7

lifecycle:
  post_create:
    - remote: touch /tmp/test

suites:
  - name: default

Expected Result

The test should complete.

Actual Result

Heavily trimmed to show only relevant bits:

       Finished creating <default-oraclelinux-7> (0m1.28s).
       [Docker] Executing command on container
       /bin/bash: /tmp/docker-223dcbd9-16d7-4dab-9beb-0d414ebe7fc8.sh: No such file or directory
#<Thread:0x0000000140bc6e70 /Users/andrew.bobulsky/.asdf/installs/ruby/3.0.1/lib/ruby/gems/3.0.0/gems/logging-2.3.0/lib/logging/diagnostic_context.rb:471 run> terminated with exception (report_on_exception is true):
/Users/andrew.bobulsky/.asdf/installs/ruby/3.0.1/lib/ruby/gems/3.0.0/gems/kitchen-docker-2.11.0/lib/kitchen/transport/docker.rb:93:in `rescue in execute': Docker failed to execute command on container. Error Details: Failed to execute command on Linux container. Failed to execute command on Docker container. Expected process to exit with [0], but received '127' (Kitchen::Transport::Docker::DockerFailed)
---- Begin output of docker -H unix:///var/run/docker.sock exec -u kitchen 2f5d7679d5a908a0f0c192bc54e489bcc1317793697538543c868b296cc29268 /bin/bash /tmp/docker-223dcbd9-16d7-4dab-9beb-0d414ebe7fc8.sh ----
STDOUT: 
STDERR: /bin/bash: /tmp/docker-223dcbd9-16d7-4dab-9beb-0d414ebe7fc8.sh: No such file or directory
---- End output of docker -H unix:///var/run/docker.sock exec -u kitchen 

:heavy_plus_sign: Additional context

I don't currently use this transport because it doesn't support kitchen login. That's a different issue that I'll probably open separately.

RulerOf avatar Dec 22 '21 16:12 RulerOf