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

volume mount issues with `oc import docker-compose ...` #8960

Closed
containscafeine opened this Issue May 20, 2016 · 2 comments

Comments

Projects
None yet
5 participants
@containscafeine

containscafeine commented May 20, 2016

Hi,

I was trying out the oc import docker-compose ... feature, and I tried to deploy an example voting app, which runs fine with docker-compose up -d

Directory structure :

# tree -L 2
.
├── docker-compose.yml
├── LICENSE
├── README.md
├── registry.yaml
├── result-app
│   ├── Dockerfile
│   ├── package.json
│   ├── server.js
│   └── views
├── voting-app
│   ├── app.py
│   ├── Dockerfile
│   ├── requirements.txt
│   ├── static
│   ├── templates
│   └── utils
└── worker
    ├── Dockerfile
    ├── pom.xml
    └── src

8 directories, 12 files

docker-compose.yaml :

# cat docker-compose.yml 
version: "2"

services:
  voting-app:
    build: ./voting-app/.
    volumes:
     - ./voting-app:/app
    ports:
      - "5000:80"
    networks:
      - front-tier
      - back-tier

  result-app:
    build: ./result-app/.
    volumes:
      - ./result-app:/app
    ports:
      - "5001:80"
    networks:
      - front-tier
      - back-tier

  worker:
    image: containscafeine/worker:stock
    networks:
      - back-tier

  redis:
    image: redis:latest
    container_name: redis
    ports: ["6379"]
    networks:
      - back-tier

  db:
    image: postgres:9.4
    container_name: db
    ports: ["5432"]
    volumes:
      - "db-data:/var/lib/postgresql/data"
    networks:
      - back-tier

volumes:
  db-data:

networks:
  front-tier:
  back-tier:

The oc import ... command runs just fine :

# oc import docker-compose -f docker-compose.yml
--> Deploying template example-voting-app
--> Importing compose file ...
    imagestream "result-app" creating
    buildconfig "result-app" creating
    imagestream "voting-app" creating
    buildconfig "voting-app" creating
    imagestream "db" creating
    deploymentconfig "db" creating
    imagestream "redis" creating
    deploymentconfig "redis" creating
    deploymentconfig "result-app" creating
    deploymentconfig "voting-app" creating
    imagestream "worker" creating
    deploymentconfig "worker" creating
    service "db" creating
    service "redis" creating
    service "result-app" creating
    service "voting-app" creating
--> Success

However, after the voting-app and result-app containers are built and deployed, they are not able to access the mounted volumes which have the code required to run the application :

# oc logs voting-app-1-oot1j
python: can't open file 'app.py': [Errno 2] No such file or directory

# oc logs result-app-1-4wl9d
module.js:341
    throw err;
    ^

Error: Cannot find module '/app/server.js'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:148:18)
    at node.js:405:3

After digging into it, oc import docker-compose -f docker-compose.yml --as-template=bday -o yaml shows me this :

- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    creationTimestamp: null
...
...
      spec:
        containers:
        - image: result-app
          name: result-app
          ports:
          - containerPort: 80
          resources: {}
          volumeMounts:
          - mountPath: /app
            name: dir-1
        volumes:
        - emptyDir: {}
          name: dir-1
...
...
      spec:
        containers:
        - image: voting-app
          name: voting-app
          ports:
          - containerPort: 80
          resources: {}
          volumeMounts:
          - mountPath: /app
            name: dir-1
        volumes:
        - emptyDir: {}
          name: dir-1
...
...

Somehow, OpenShift mounts empty directories instead of the specified ones (in docker-compose.yaml) and hence the application is unable to access the content from the mounted volumes.

I, then, removed the volume mounts from docker-compose.yaml and copied the content inside the container otherwise, and the application works.

Version
# oc version
oc v1.3.0-alpha.0-581-gcf6465c-dirty
kubernetes v1.3.0-alpha.1-331-g0522e63
Steps To Reproduce
  1. oc new-project voting-app
  2. oadm policy add-scc-to-user anyuid -n voting-app -z default
  3. oc import docker-compose -f docker-compose.yml
  4. oc logs -f result-app-1-xxxxx
  5. oc logs -f voting-app-1-xxxxx
Current Result

The application fails to deploy due to empty volumes being mounted instead the specified ones.

Expected Result

The current volumes are mounted inside the pods as stated in the docker-compose.yaml file.

Additional Information

$ oadm diagnostics - http://paste.fedoraproject.org/368982/61265146/
$ oc get all -o json -n bday-mounts - http://paste.fedoraproject.org/368983/14637612/

@openshift-bot

This comment has been minimized.

Show comment
Hide comment
@openshift-bot

openshift-bot Feb 6, 2018

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot commented Feb 6, 2018

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.

/lifecycle stale

@containscafeine

This comment has been minimized.

Show comment
Hide comment
@containscafeine

containscafeine Feb 6, 2018

Closing this since this is no longer applicable!

containscafeine commented Feb 6, 2018

Closing this since this is no longer applicable!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment