Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2018-06-14T11:49:18.237Z
Answers: I consider adding repos by hand is not a must if same docker run statement works, see update
Answers: Ta Mu
Answers: CC BY-SA 3.0
Answers: 2017-11-26T11:29:58.667Z
Answers: 2017-11-26T11:29:58.667Z
Answers: 030
Body: <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>
  
Comments: CC BY-SA 3.0
Comments: 2017-07-04T07:51:05.613Z
Comments: As your log say: `Use 'zypper addrepo' or 'zypper modifyrepo' commands to add or enable repositories.` before your first RUN command ??
Comments: Tensibai
Comments: CC BY-SA 4.0
Comments: 2018-06-14T11:39:50.513Z
Comments: @Tensibai update - same docker run statement works however; what's the difference?
Comments: Ta Mu
Comments: CC BY-SA 4.0
Comments: 2018-06-14T12:09:29.163Z
Comments: 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.
Comments: Tensibai
Comments: CC BY-SA 4.0
Comments: 2018-06-14T12:15:16.033Z
Comments: this is what I am thinking whether this is specific issue to the enterprise version.
Comments: Ta Mu
Comments: CC BY-SA 4.0
Comments: 2018-06-14T12:26:34.823Z
Comments: 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
Comments: Tensibai
Tags: <containers><dockerfile>
Title: How to make custom SLES (SuSe Linux Enterprise) Dockerfiles?
UserDisplayName: Ta Mu
ThreadText: # 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  
  
  ---
  
  