Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "BaSyx / Documentation / Components / Docker"
m (Adds missing "CMD" in Dockerfile) |
m (Daniel.Espen.iese.fraunhofer.de moved page BaSyx / Examples / Deployment With Docker to BaSyx / Docker Images: Need separate pages about docker - more information will be added on this topic) |
(No difference)
|
Revision as of 12:53, 10 March 2020
The following examples for deployment with docker assume an already installed docker environment.
Dockerfile
Java
To deploy an arbitrary resource (Asset Administration Shell, Sub Model, Registry, ...) with Docker, the resource has to be packaged with a server in a jar first. It is also possible to package several resources into a single jar and deploy them together.
In the following, it is assumed that the resource is already packaged in a jar file.
The following Dockerfile can be used to package arbitrary jars and expose their port(s). ${jar-name} is here the name of the jar file.
# Add java runtime environment for execution FROM java:8-jdk-alpine COPY ${jar-name}.jar /usr/share/${jar-name}.jar # Expose the appropriate port. In case of Tomcat, this is 8080. EXPOSE 8080 # Start the jar CMD java -jar "/usr/share/${jar-name}.jar"
After building the jar, the image named ${image-name} can be build using
docker build -t ${image-name} .
You can choose any arbitrary image name. Next, the container can be started. To do this, use the following command:
docker run -p${host-port}:8080 ${image-name}
${host-port} can be an arbitrary chosen port that is currently not in use on the host system. If another port than 8080 was exposed by the Dockerfile, the port has to change appropriately in the docker run command.