How to make custom SLES (SuSe Linux Enterprise) Dockerfiles? 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
 ---&gt; d0f7e807658b
Step 2/3 : RUN zypper ref -s
 ---&gt; 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.
 ---&gt; 21e8beb32227
Removing intermediate container 235316f5bbe1
Step 3/3 : RUN zypper --gpg-auto-import-keys ref -s
 ---&gt; 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]
 ---&gt; 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).
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.