Two things.
- You have used
CMD
twice.
CMD
can only be used once, think of it as the purpose of your docker image. Every time a container is run, it will always execute CMD
if you want multiple commands, you should use RUN
and then lastly, used CMD
FROM openjdk:
MAINTAINER MyPerson
WORKDIR /usr/src/
ENTRYPOINT ["cp"]
RUN /usr/src/myapp
RUN ls /usr/src/myapp
- Copying stuff into image
There is a simple command
COPY
the syntax being COPY <from-here> <to-here>
Seems like you want to run myjavaimage
so what you will do is
COPY /path/to/myjavaimage /myjavaimage
CMD myjavaimage MainClass.java
Where you see the arrows, I've just written dummy code. Replace that with the correct code.
Also, your Dockerfile is badly created.
ENTRYPOINT -> not sure why you'd do "cp", but it's an actual entrypoint. Could point to the root dir of your project or to an app that will be run.
Don't understand why you want to do ls /usr/src/myapp
but if you do want to do it, use RUN
and not CMD
Lastly,
Best way to debug docker containers are in interactive mode. That means ssh'ing in to your container, have a look around, run code, and see what is the problem.
Run this: docker run -it <image-name> /bin/bash
and then have a look inside and it's usually the best way to see what causes issues.