creating-docker-images.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <!DOCTYPE html
  2. SYSTEM "about:legacy-compat">
  3. <html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="copyright" content="(C) Copyright 2020"><meta name="DC.rights.owner" content="(C) Copyright 2020"><meta name="DC.type" content="task"><meta name="description" content="To install custom plug-ins or make other changes based on the DITA-OT parent image, you can create your own Dockerfile and specify the official DITA-OT image as the basis for your image."><meta name="DC.subject" content="plug-ins, installing in Docker images, Docker images"><meta name="keywords" content="plug-ins, installing in Docker images, Docker images"><meta name="DC.relation" scheme="URI" content="../topics/using-docker-images.html"><meta name="DC.format" content="HTML5"><meta name="DC.identifier" content="ID"><link rel="stylesheet" type="text/css" href="../css/commonltr.css"><link rel="stylesheet" type="text/css" href="../css/dita-ot-doc.css"><title>Installing plug-ins in a Docker image</title></head><body id="ID"><header role="banner"><div class="header">
  4. <p>DITA Open Toolkit</p>
  5. <hr>
  6. </div></header><nav role="toc"><ul><li><a href="../index.html">DITA Open Toolkit 3.5</a></li><li><a href="../release-notes/index.html">Release Notes</a></li><li><a href="../topics/installing-client.html">Installing DITA-OT</a></li><li><a href="../topics/building-output.html">Building output</a><ul><li><a href="../topics/build-using-dita-command.html">Using the dita command</a></li><li><a href="../topics/using-docker-images.html">Using Docker images</a><ul><li class="active"><a href="../topics/creating-docker-images.html">Custom images</a></li></ul></li><li><a href="../topics/publishing-with-ant.html">Using Ant</a></li><li><a href="../reference/java-api.html">Using the Java API</a></li></ul></li><li><a href="../topics/input-formats.html">Authoring formats</a></li><li><a href="../topics/output-formats.html">Output formats</a></li><li><a href="../parameters/index.html">Parameters</a></li><li><a href="../topics/html-customization.html">Customizing HTML</a></li><li><a href="../topics/pdf-customization.html">Customizing PDF</a></li><li><a href="../topics/adding-plugins.html">Adding plug-ins</a></li><li><a href="../topics/custom-plugins.html">Creating plug-ins</a></li><li><a href="../topics/troubleshooting-overview.html">Troubleshooting</a></li><li><a href="../reference/index.html">Reference</a></li><li><a href="../topics/dita-and-dita-ot-resources.html">Resources</a></li></ul></nav><main role="main"><article role="article" aria-labelledby="ariaid-title1">
  7. <h1 class="title topictitle1" id="ariaid-title1">Installing plug-ins in a Docker image</h1>
  8. <div class="body taskbody"><p class="shortdesc">To install custom plug-ins or make other changes based on the DITA-OT parent image, you can create your own
  9. <span class="ph filepath">Dockerfile</span> and specify the official DITA-OT image as the basis for your image. </p>
  10. <section class="section context"><div class="tasklabel"><h2 class="sectiontitle tasklabel">About this task</h2></div>
  11. <p class="p">Each subsequent declaration in the Dockerfile modifies this parent image, so you can start with the official
  12. image, and add custom plug-ins or other commands as required to create a custom Docker image that includes
  13. everything you need to publish your content.</p></section>
  14. <section><div class="tasklabel"><h2 class="sectiontitle tasklabel">Procedure</h2></div><ol class="ol steps"><li class="li step stepexpand">
  15. <span class="ph cmd">Create a new <span class="ph filepath">Dockerfile</span> and specify the official DITA-OT image in the
  16. <span class="ph filepath">FROM</span> directive.</span>
  17. <div class="itemgroup stepxmp">
  18. <pre class="pre codeblock language-dockerfile normalize-space show-line-numbers show-whitespace"><code># Use the latest official DITA-OT image as parent: ↓
  19. FROM docker.pkg.github.com/dita-ot/dita-ot/dita-ot:3.5</code></pre>
  20. </div>
  21. </li><li class="li step stepexpand"><strong>Optional: </strong>
  22. <span class="ph cmd">You can extend your image with a <code class="ph codeph">RUN</code> declaration that runs the <span class="keyword cmdname">dita</span>
  23. command from the container to install a custom plug-in, and specify the filename or URL of the plug-in’s
  24. distribution ZIP file.</span>
  25. <div class="itemgroup stepxmp">
  26. <pre class="pre codeblock language-dockerfile normalize-space show-line-numbers show-whitespace"><code># Install a custom plug-in from a remote location:
  27. RUN dita --install https://github.com/infotexture/dita-bootstrap/archive/3.3.zip</code></pre>
  28. </div>
  29. </li><li class="li step stepexpand"><strong>Optional: </strong>
  30. <span class="ph cmd">You can also install custom plug-ins from the main DITA-OT plug-in registry at
  31. <a class="xref" href="https://www.dita-ot.org/plugins" target="_blank" rel="external noopener">dita-ot.org/plugins</a>, or from your company plug-in registry.</span>
  32. <div class="itemgroup stepxmp">
  33. <pre class="pre codeblock language-dockerfile normalize-space show-line-numbers show-whitespace"><code># Install from the registry at dita-ot.org/plugins:
  34. RUN dita --install org.dita-community.pdf-page-break</code></pre>
  35. </div>
  36. </li></ol></section>
  37. <section class="example"><div class="tasklabel"><h2 class="sectiontitle tasklabel">Example</h2></div>
  38. <p class="p">The <span class="ph filepath">docsrc/samples</span> folder in the DITA-OT installation directory contains a complete
  39. example:</p>
  40. <figure class="fig fignone"><figcaption><span class="fig--title-label">Figure 1. </span>Sample Dockerfile with custom plug-ins: <span class="ph filepath"><var class="keyword varname">dita-ot-dir</var>/docsrc/samples</span><span class="ph filepath">/docker/Dockerfile</span></figcaption>
  41. <pre class="pre codeblock language-dockerfile normalize-space show-line-numbers show-whitespace"><code># Use the latest official DITA-OT image as parent: ↓
  42. FROM docker.pkg.github.com/dita-ot/dita-ot/dita-ot:3.5
  43. # Install a custom plug-in from a remote location:
  44. RUN dita --install https://github.com/infotexture/dita-bootstrap/archive/3.3.zip
  45. # Install from the registry at dita-ot.org/plugins:
  46. RUN dita --install org.dita-community.pdf-page-break</code></pre>
  47. </figure>
  48. </section>
  49. <section class="example"><h2 class="title sectiontitle">Building a new image</h2>
  50. <p class="p">You can build a Docker image from this example by running the following command from the <span class="ph filepath"><var class="keyword varname">dita-ot-dir</var>/docsrc/samples</span> directory:</p>
  51. <pre class="pre codeblock"><code>$ <span class="keyword cmdname">docker</span> image build -t sample-docker-image:1.0 .
  52. Sending build context to Docker daemon 2.048kB
  53. Step 1/3 : FROM docker.pkg.github.com/dita-ot/dita-ot/dita-ot:<span class="keyword">3.5</span>
  54. ---&gt; 9abb96827538
  55. Step 2/3 : RUN dita --install https://github.com/infotexture/dita-bootstrap/archive/3.3.zip
  56. ---&gt; Running in d510f874cae0
  57. Added net.infotexture.dita-bootstrap
  58. Removing intermediate container d510f874cae0
  59. ---&gt; 63deb8e15b5b
  60. Step 3/3 : RUN dita --install org.dita-community.pdf-page-break
  61. ---&gt; Running in b4ef2fcad916
  62. Added org.dita-community.pdf-page-break
  63. Removing intermediate container b4ef2fcad916
  64. ---&gt; 402885636b7f
  65. Successfully built 402885636b7f
  66. Successfully tagged sample-docker-image:1.0
  67. </code></pre>
  68. <p class="p">Docker steps through each instruction in the Dockerfile to build the sample image. In this case, the
  69. <span class="keyword cmdname">dita</span> command provides feedback on each installed plug-in.</p>
  70. </section>
  71. <section class="example"><h2 class="title sectiontitle">Running the new container</h2>
  72. <p class="p">You can then start a container based on your new image:</p>
  73. <pre class="pre codeblock"><code>$ <span class="keyword cmdname">docker</span> container run -it \
  74. -v /path/to/dita-ot-dir/docsrc:/src sample-docker-image:1.0 \
  75. -i /src/userguide.ditamap \
  76. -o /src/out/dita-bootstrap \
  77. -f html5-bootstrap -v</code></pre>
  78. <div class="p">This command sequence specifies the following options:
  79. <ul class="ul">
  80. <li class="li"><span class="keyword option">-v</span> mounts the <span class="ph filepath">docsrc</span> subfolder of the DITA-OT directory on your host
  81. machine and binds it to the <span class="ph filepath">/src</span> volume in the container</li>
  82. <li class="li"><span class="keyword option">-i</span> specifies <span class="ph filepath"><var class="keyword varname">dita-ot-dir</var>/docsrc</span><span class="ph filepath">/userguide.ditamap</span> as the input map file</li>
  83. <li class="li"><span class="keyword option">-o</span> writes the output to <span class="ph filepath"><var class="keyword varname">dita-ot-dir</var>/docsrc</span><span class="ph filepath">/out/dita-bootstrap</span></li>
  84. <li class="li"><span class="keyword option">-f</span> sets the output format to the Bootstrap template, and</li>
  85. <li class="li"><span class="keyword option">-v</span> displays build progress messages with verbose logging</li>
  86. </ul>
  87. </div>
  88. <p class="p">When the build is finished, you should find a copy of the DITA-OT documentation under <span class="ph filepath"><var class="keyword varname">dita-ot-dir</var>/docsrc</span><span class="ph filepath">/out/dita-bootstrap</span>, styled with the basic Bootstrap
  89. template from the custom plug-in.</p>
  90. </section>
  91. </div>
  92. <nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../topics/using-docker-images.html" title="Docker is a platform used to build, share, and run portable application containers. As of version 3.4, the DITA-OT project provides an official Docker container image that includes everything you need to run the toolkit and publish DITA content from a containerized environment.">Running the dita command from a Docker image</a></div></div></nav></article></main></body></html>