0

To use a dockerized SLES, you need to use an official base image and run it on a SLES host.

But this does not seem to work out of the box - what needs to be done to build a custom image?

Dockerfile:

FROM suse/sles12:latest
RUN zypper ref -s
RUN zypper --gpg-auto-import-keys ref -s

Docker build output - image will be created but obviously it is not possible to install any packages because the central repo seems to be not preconfigured.

Vendor documentation: https://www.suse.com/documentation/sles-12/book_sles_docker/data/customizing_pre-build_images.html

Sending build context to Docker daemon  3.584kB
Step 1/3 : FROM suse/sles12:latest
 ---> d0f7e807658b
Step 2/3 : RUN zypper ref -s
 ---> Running in 235316f5bbe1
Refreshing service 'container-suseconnect'.
Problem retrieving the repository index file for service 'container-suseconnect':
[container-suseconnect|file:/usr/lib/zypp/plugins/services/container-suseconnect]
Warning: Skipping service 'container-suseconnect' because of the above error.
All services have been refreshed.
Warning: There are no enabled repositories defined.
Use 'zypper addrepo' or 'zypper modifyrepo' commands to add or enable repositories.
 ---> 21e8beb32227
Removing intermediate container 235316f5bbe1
Step 3/3 : RUN zypper --gpg-auto-import-keys ref -s
 ---> Running in 72ba1ad22da8
Refreshing service 'container-suseconnect'.
Warning: Skipping service 'container-suseconnect' because of the above error.
All services have been refreshed.
Warning: There are no enabled repositories defined.
Use 'zypper addrepo' or 'zypper modifyrepo' commands to add or enable repositories.
Problem retrieving the repository index file for service 'container-suseconnect':
[container-suseconnect|file:/usr/lib/zypp/plugins/services/container-suseconnect]
 ---> 6426e55c2d87
Removing intermediate container 72ba1ad22da8
Successfully built 6426e55c2d87

UPD. While this one is working:

 docker run -it suse/sles12 bash -c "zypper -n ref -s"
 Adding repository 'SLES12-Debuginfo-Pool for sle-12-x86_64' ...[done]
 .....

UPD. Finally, the following worked for me: run a container, install everything there and finally commit the container to a new image (docker commit container-id image).

5
  • As your log say: Use 'zypper addrepo' or 'zypper modifyrepo' commands to add or enable repositories. before your first RUN command ??
    – Tensibai
    Jul 4 '17 at 7:51
  • @Tensibai update - same docker run statement works however; what's the difference? Jun 14 '18 at 11:39
  • That's not the same statement bash -c "zypper -n ref -s" is not the same as zypper ref -s. Running with -it make the container interactive (gets a tty, where a dockerfile doesn't). So there's plenty of differences between your two tests. Considering this is a pay product question, the question would probably be better directed to Suse's support than a community thing.
    – Tensibai
    Jun 14 '18 at 12:09
  • this is what I am thinking whether this is specific issue to the enterprise version. Jun 14 '18 at 12:15
  • Considering your working exemple, I'm tempted to guess it's more related to some env variable loaded by bash or the presence of a tty in your interactive exemple, you may try docker run suse/sles12 "zypper -n ref -s"to better reproduce what is in the dockerfile and then a docker logs <container> to see what it says
    – Tensibai
    Jun 14 '18 at 12:26
1

As @Tensibai already indicated in one of the comments, some packages are missing:

Use 'zypper addrepo' or 'zypper modifyrepo' commands to add or enable repositories.

Either use zypper addrepo or zypper modifyrepo in your dockerfile to solve the issue.

1
  • I consider adding repos by hand is not a must if same docker run statement works, see update Jun 14 '18 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.