2

I want to create nexus 3 docker with pre-define configuration (few repos and dummy artifacts) for testing my library.

I can't call the nexus API from the docker file, because it require running nexus.

I tried to up the nexus 3 container, config it manually and create image from container

docker commit ...

the new image created, but when I start the new container from it, it doesn't contains all my manual configuration that I did before.

How can I customize the nexus 3 image?

Shurik
  • 562
  • 1
  • 7
  • 19

1 Answers1

2

If I understand well, you are trying to create a portable, standalone customized nexus3 installation in a self-contained docker image for testing/distribution purpose.

Doing this by extending the official nexus3 docker image will not work. Have a look at their Dockerfile: it defines a volume for /nexus_data and there is currently no way of removing this from a child image.

It means that when your start a container without any specific options, a volume is created for each new container. This is why your committed image starts with blank data. The best you can do is to name the data volume when you start the container (option -v nexus_data:/nexus_data for docker run) so that the same volume is being reused. But the data will still be in your local docker installation, not in the image.

To do what you wish, you need to recreate you own docker image without a data volume. You can do it from the above official Dockerfile, just remove the volume line. Then you can customize and commit your container to an image which will contain the data.

Zeitounator
  • 38,476
  • 7
  • 53
  • 66
  • 1
    Note that if you start nexus during the build phase in the same Dockerfile, you can create your needed contents through the api, shutdown nexus, cleanup and you're done. – Zeitounator Apr 15 '19 at 15:47