Example of taking a docker image and modifying it using a Dockerfile
Create the DockerFile
This dockerfile will specify an initial docker image and perform some tasks on it. This will result in the creation of a new image when we issue the docker build command.
...
- specify the starting docker image
- copy files into the image
- run commands in the image
- specify the internal ports that will be used by the image
- define the entrypoint (what gets executed at image startup)
Dockerfile
Code Block | ||
---|---|---|
| ||
FROM jamesdbloom/mockserver |
...
LABEL placodermi.component=mockserver |
...
WORKDIR /opt/mockserver |
...
# Artifacts COPY entrypoint.sh /opt/mockserver/entrypoint.sh |
...
COPY MockInitializer.java /opt/mockserver/MockInitializer.java |
...
RUN chmod +x /opt/mockserver/entrypoint.sh |
...
EXPOSE 1080 EXPOSE 1090 ENTRYPOINT ["/opt/mockserver/entrypoint.sh"] |
Build the Image
Run the Dockerfile by issuing the following command
...
ie. > docker rim mockserver_image
Run the image
Now that you have your image, you can run this image by issuing the following command:
...
ie. > docker run -it --rm --entrypoint bash mockserver_image
Make a Container
Now that you have confirmed that the image works, you can make it a container by issuing the following command:
...
That's the general basics of it all.
Creating a New Container in CloakedJS using Ansible
If you want to create a docker container in CloakedJS, have a look at the mockserver implementation in the following folders:
...
folder/file
...
Purpose
...
folder/file
...
Purpose
...
Define the building of the image. Folder structure:
...
Define the building of the container.
Folder structure:
...
Script to run the tasks mentioned above to build and deploy the docker image/container.
...