Docker Image Operations - Create a New Image by Writing Over an Existing Image: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * Image Operations * Dockerfile =Overview= This example demonstrate how to modify an existing Postgresql imag...")
 
No edit summary
Line 6: Line 6:
=Overview=
=Overview=


This example demonstrate how to modify an existing Postgresql image to add debugging output to the setup logic.
This example demonstrate how to modify an existing Postgresql image by creating a new image with a very thin modification on top. In this case we add debugging output to the setup logic in form of a new run script. Alternatively, we can modify the CMD sequence and layer it in top of the existing image.


=Procedure=
=Procedure=
Line 19: Line 19:
FROM registry.access.redhat.com/rhscl/postgresql-95-rhel7:latest
FROM registry.access.redhat.com/rhscl/postgresql-95-rhel7:latest
COPY ./run-postgresql /usr/bin/
COPY ./run-postgresql /usr/bin/
</syntaxhighlight>


Alternatively (we are assuming a hypothetical my-app that can be started in debug mode by passing --debug, which did not exist in the "FROM" image:
<syntaxhighlight lang='docker'>
FROM ...
CMD ["my-app", "--debug", "start"]
</syntaxhighlight>
</syntaxhighlight>



Revision as of 22:32, 15 August 2019

Internal

Overview

This example demonstrate how to modify an existing Postgresql image by creating a new image with a very thin modification on top. In this case we add debugging output to the setup logic in form of a new run script. Alternatively, we can modify the CMD sequence and layer it in top of the existing image.

Procedure

Stage New Content

Use the local directory as staging area. Place a new run-postgreql with extra debug output.

Write the Dockerfile

FROM registry.access.redhat.com/rhscl/postgresql-95-rhel7:latest
COPY ./run-postgresql /usr/bin/

Alternatively (we are assuming a hypothetical my-app that can be started in debug mode by passing --debug, which did not exist in the "FROM" image:

FROM ...
CMD ["my-app", "--debug", "start"]

Build the Image

docker build -t novaordis/postgresql-debug .

The new image will be placed in the local registry as "novaordis/postgresql-debug:latest".

Run the Image

docker run -e -e POSTGRESQL_USER=... -e POSTGRESQL_PASSWORD=... -e POSTGRESQL_DATABASE=... novaordis/postgresql-debug