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

<pre><code>Use 'zypper addrepo' or 'zypper modifyrepo' commands to add or enable repositories.
</code></pre>

<p>Either use <code>zypper addrepo</code> or <code>zypper modifyrepo</code> in your dockerfile to solve the issue.</p>

CC BY-SA 4.0
2018-06-14T11:49:18.237Z
I consider adding repos by hand is not a must if same docker run statement works, see update
Ta Mu
CC BY-SA 3.0
2017-11-26T11:29:58.667Z
2017-11-26T11:29:58.667Z
030
<p>To use a dockerized SLES, you need to use an official base image and run it on a SLES host. </p>

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

<p>Dockerfile:</p>

<pre><code>FROM suse/sles12:latest
RUN zypper ref -s
RUN zypper --gpg-auto-import-keys ref -s
</code></pre>

<p>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.</p>

<p>Vendor documentation: <a href="https://www.suse.com/documentation/sles-12/book_sles_docker/data/customizing_pre-build_images.html" rel="nofollow noreferrer">https://www.suse.com/documentation/sles-12/book_sles_docker/data/customizing_pre-build_images.html</a></p>

<pre><code>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
</code></pre>

<p>UPD. While this one is working:</p>

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

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

CC BY-SA 3.0
2017-07-04T07:51:05.613Z
As your log say: `Use 'zypper addrepo' or 'zypper modifyrepo' commands to add or enable repositories.` before your first RUN command ??
Tensibai
CC BY-SA 4.0
2018-06-14T11:39:50.513Z
@Tensibai update - same docker run statement works however; what's the difference?
Ta Mu
CC BY-SA 4.0
2018-06-14T12:09:29.163Z
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
CC BY-SA 4.0
2018-06-14T12:15:16.033Z
this is what I am thinking whether this is specific issue to the enterprise version.
Ta Mu
CC BY-SA 4.0
2018-06-14T12:26:34.823Z
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
<containers><dockerfile>
How to make custom SLES (SuSe Linux Enterprise) Dockerfiles?
Ta Mu
# How to make custom SLES (SuSe Linux Enterprise) Dockerfiles?

(Asked by: username_0 on 2017-07-03)

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).

**Tags:** containers, dockerfile

> **Comments:**
> **username_1**: As your log say: `Use 'zypper addrepo' or 'zypper modifyrepo' commands to add or enable repositories.` before your first RUN command ??  
> **username_0**: @username_1 update - same docker run statement works however; what's the difference?  
> **username_1**: 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.  
> **username_0**: this is what I am thinking whether this is specific issue to the enterprise version.  
> **username_1**: 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  

---

## 1 answers

### Answer by username_2 on 2017-11-26. Score: 1

As @username_1 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.

> **Comments:**
> **username_0**: I consider adding repos by hand is not a must if same docker run statement works, see update  

---

