Skip to content
This repository has been archived by the owner on Mar 23, 2019. It is now read-only.

Import fails when Dockerfile contains ADD with a directory #573

Closed
LeHack opened this issue Jun 2, 2017 · 1 comment
Closed

Import fails when Dockerfile contains ADD with a directory #573

LeHack opened this issue Jun 2, 2017 · 1 comment
Labels

Comments

@LeHack
Copy link

LeHack commented Jun 2, 2017

  • Bug Report
Dockerfile
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /project
WORKDIR /project
ADD requirements.txt /project/
RUN pip install -r requirements.txt
ADD testapp /project/
RUN /project/manage.py migrate
CMD ["python3", "/project/manage.py", "runserver", "0.0.0.0:8000"]
SUMMARY

The import command fails when the Dockerfile contains the ADD command pointing to a directory.

WORKAROUND

Replacing ADD with COPY resolves the issue.

STEPS TO REPRODUCE
  1. Save the Dockerfile into a new directory
  2. Inside that directory create another one named "testapp"
  3. Run ansible-container import .
EXPECTED RESULTS

Project correctly imported to ansible-container.

ACTUAL RESULTS
$ ansible-container import .
ERROR	Unknown exception	
Traceback (most recent call last):
  File "/home/.../lib/python3.5/site-packages/container/cli.py", line 268, in __call__
    getattr(core, u'hostcmd_{}'.format(args.subcommand))(**vars(args))
  File "/home/.../lib/python3.5/site-packages/container/__init__.py", line 28, in __wrapped__
    return fn(*args, **kwargs)
  File "/home/.../lib/python3.5/site-packages/container/core.py", line 425, in hostcmd_import
    engine_obj.import_project(base_path, **kwargs)
  File "/home/.../lib/python3.5/site-packages/container/__init__.py", line 28, in __wrapped__
    return fn(*args, **kwargs)
  File "/home/.../lib/python3.5/site-packages/container/docker/engine.py", line 769, in import_project
    dfi.run()
  File "/home/.../lib/python3.5/site-packages/container/docker/importer.py", line 489, in run
    (list(parser), os.path.join(self.role_path, 'tasks', 'main.yml')),
  File "/home/.../lib/python3.5/site-packages/container/docker/importer.py", line 187, in __iter__
    comments=preparsed.get('comments', [])):
  File "/home/.../lib/python3.5/site-packages/container/docker/importer.py", line 40, in __wrapped__
    to_return = fn(self, payload, comments, **kwargs)
  File "/home/.../lib/python3.5/site-packages/container/docker/importer.py", line 347, in parse_ADD
    _ = tarfile.open(real_path, mode='r:*')
  File "/home/.../lib/python3.5/tarfile.py", line 1559, in open
    return func(name, "r", fileobj, **kwargs)
  File "/home/.../lib/python3.5/tarfile.py", line 1657, in bz2open
    compresslevel=compresslevel)
  File "/home/.../python3.5/lib/python3.5/bz2.py", line 95, in __init__
    self._fp = _builtin_open(filename, mode)
IsADirectoryError: [Errno 21] Is a directory: './testapp'
OS / ENVIRONMENT
$ ansible-container --debug version
Ansible Container, version 0.9.1
Linux, localhost, 4.4.0-79-generic, #100~14.04.1-Ubuntu SMP Fri May 19 18:36:51 UTC 2017, x86_64
3.5.3 (default, May  6 2017, 00:22:52) 
[GCC 4.8.4] /home/...VirtEnv.../bin/python3.5
{
  "ClusterStore": "",
  "SwapLimit": false,
  "SystemStatus": null,
  "CPUShares": true,
  "InitBinary": "docker-init",
  "MemTotal": 6102839296,
  "IPv4Forwarding": true,
  "OperatingSystem": "Ubuntu 14.04.5 LTS",
  "Plugins": {
    "Network": [
      "bridge",
      "host",
      "macvlan",
      "null",
      "overlay"
    ],
    "Volume": [
      "local"
    ],
    "Authorization": null
  },
  "MemoryLimit": true,
  "SystemTime": "2017-06-02T12:07:31.655921233+02:00",
  "ContainersRunning": 1,
  "Swarm": {
    "RemoteManagers": [
      {
        "Addr": "192.168.1.10:2377",
        "NodeID": "z5ltpxxmb4kibrtzoubx1jzjj"
      }
    ],
    "Nodes": 4,
    "NodeID": "z5ltpxxmb4kibrtzoubx1jzjj",
    "NodeAddr": "192.168.1.10",
    "LocalNodeState": "active",
    "ControlAvailable": true,
    "Error": "",
    "Cluster": {
      "ID": "7s5h0wgo55z4aa279t8thuk3r",
      "CreatedAt": "2017-06-01T14:28:26.191390983Z",
      "Version": {
        "Index": 174
      },
      "UpdatedAt": "2017-06-02T02:28:26.194754185Z",
      "Spec": {
        "CAConfig": {
          "NodeCertExpiry": 7776000000000000
        },
        "Raft": {
          "HeartbeatTick": 1,
          "ElectionTick": 3,
          "SnapshotInterval": 10000,
          "KeepOldSnapshots": 0,
          "LogEntriesForSlowFollowers": 500
        },
        "TaskDefaults": {},
        "EncryptionConfig": {
          "AutoLockManagers": false
        },
        "Dispatcher": {
          "HeartbeatPeriod": 5000000000
        },
        "Orchestration": {
          "TaskHistoryRetentionLimit": 5
        },
        "Name": "default"
      }
    },
    "Managers": 1
  },
  "CpuCfsPeriod": true,
  "Labels": null,
  "NoProxy": "",
  "LoggingDriver": "json-file",
  "BridgeNfIp6tables": true,
  "RegistryConfig": {
    "Mirrors": [],
    "IndexConfigs": {
      "docker.io": {
        "Mirrors": null,
        "Secure": true,
        "Official": true,
        "Name": "docker.io"
      },
      "docker-host:5000": {
        "Mirrors": [],
        "Secure": false,
        "Official": false,
        "Name": "docker-host:5000"
      }
    },
    "InsecureRegistryCIDRs": [
      "127.0.0.0/8"
    ]
  },
  "ContainersStopped": 0,
  "Isolation": "",
  "NCPU": 4,
  "ServerVersion": "17.03.1-ce",
  "Images": 10,
  "KernelMemory": true,
  "Name": "samuraj.pl",
  "NGoroutines": 159,
  "Driver": "aufs",
  "ContainersPaused": 0,
  "CpuCfsQuota": true,
  "DriverStatus": [
    [
      "Root Dir",
      "/var/lib/docker/aufs"
    ],
    [
      "Backing Filesystem",
      "extfs"
    ],
    [
      "Dirs",
      "25"
    ],
    [
      "Dirperm1 Supported",
      "true"
    ]
  ],
  "HttpsProxy": "",
  "ID": "WATP:X33H:FWGQ:BAEX:CHVS:L3NA:KXEC:RFCU:B3VN:AANJ:PDDJ:OGLE",
  "LiveRestoreEnabled": false,
  "OSType": "linux",
  "DockerRootDir": "/var/lib/docker",
  "OomKillDisable": true,
  "NFd": 39,
  "CPUSet": true,
  "BridgeNfIptables": true,
  "SecurityOptions": [
    "name=apparmor"
  ],
  "KernelVersion": "4.4.0-79-generic",
  "CgroupDriver": "cgroupfs",
  "NEventsListener": 0,
  "Containers": 1,
  "ClusterAdvertise": "",
  "HttpProxy": "",
  "DefaultRuntime": "runc",
  "InitCommit": {
    "Expected": "949e6fa",
    "ID": "949e6fa"
  },
  "Debug": false,
  "Architecture": "x86_64",
  "IndexServerAddress": "https://index.docker.io/v1/",
  "RuncCommit": {
    "Expected": "54296cf40ad8143b62dbcaa1d90e520a2136ddfe",
    "ID": "54296cf40ad8143b62dbcaa1d90e520a2136ddfe"
  },
  "ContainerdCommit": {
    "Expected": "4ab9917febca54791c5f071a9d1f404867857fcc",
    "ID": "4ab9917febca54791c5f071a9d1f404867857fcc"
  },
  "Runtimes": {
    "runc": {
      "path": "docker-runc"
    }
  },
  "ExperimentalBuild": false
}
{
  "GitCommit": "c6d412e",
  "MinAPIVersion": "1.12",
  "Os": "linux",
  "Version": "17.03.1-ce",
  "Arch": "amd64",
  "KernelVersion": "4.4.0-79-generic",
  "BuildTime": "2017-03-27T17:10:36.401799458+00:00",
  "ApiVersion": "1.27",
  "GoVersion": "go1.7.5"
}
@j00bar
Copy link
Contributor

j00bar commented Jun 2, 2017

Accepted. As a workaround until this can be fixed, using a trailing slash ought to work.

@j00bar j00bar added the bug label Jun 2, 2017
josiahg added a commit to josiahg/ansible-container that referenced this issue Jun 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants