PAA
PAA

Reputation: 12005

Docker Volume is not working for deployments

I am following lynda Docker tutorials and performing stuff related to docker compose file.

This is my docker-compose.yml file.

more docker-compose.yml
version: '3'
services:
  web:
    image: jboss/wildfly
    volumes:
      - ~/deployments:/opt/jboss/wildfly/standalone/deployments
    ports:
      - 8080:8080

As per authors, I am trying to copy webapp.war file to deployments/ folder giving me error. It look like volume mapping for the docker file is not working.

cp /home/user/Demos/docker-for-java/chapter2/webapp.war deployments/ cp: cannot create regular file ‘deployments/’: Not a directory

docker-compose ps
     Name                   Command               State           Ports
--------------------------------------------------------------------------------
helloweb_web_1   /opt/jboss/wildfly/bin/sta ...   Up      0.0.0.0:8080->8080/tcp

Upvotes: 1

Views: 899

Answers (1)

Igor Nikolaev
Igor Nikolaev

Reputation: 4717

I think you might be misinterpreting tutorial. I haven't seen the tutorial itself, but checking the documentation for the WildFly Docker image here there's a mention that you need to extend base image and add your war file inside:

To do this you just need to extend the jboss/wildfly image by creating a new one. Place your application inside the deployments/ directory with the ADD command (but make sure to include the trailing slash on the deployment folder path, more info). You can also do the changes to the configuration (if any) as additional steps (RUN command).

This means that you need to create a Dockerfile with approximately this contents (change your-awesome-app.war with the path to your war file):

FROM jboss/wildfly
ADD your-awesome-app.war /opt/jboss/wildfly/standalone/deployments/

After that you need to change you docker-compose.yml to build from your Dockerfile instead of using jboss/wildfly (note the use of build: . instead of image: jboss/wildfly):

version: '3'
services:
  web:
    build: .
    ports:
      - 8080:8080

Try that and comment if you run into any issues

Upvotes: 1

Related Questions