using-docker-images.dita 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE task PUBLIC "-//OASIS//DTD DITA General Task//EN" "generalTask.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <task id="ID">
  5. <title>Running the <cmdname>dita</cmdname> command from a Docker image</title>
  6. <titlealts>
  7. <navtitle>Using Docker images</navtitle>
  8. </titlealts>
  9. <shortdesc>
  10. <ph id="docker-desc">
  11. <xref keyref="docker"/> is a platform used to build, share, and run portable application containers. As of version
  12. 3.4, the DITA-OT project provides an official Docker container image that includes everything you need to run the
  13. toolkit and publish DITA content from a containerized environment.</ph></shortdesc>
  14. <prolog>
  15. <metadata>
  16. <keywords>
  17. <indexterm><cmdname>dita</cmdname> command
  18. <indexterm>running from Docker images</indexterm></indexterm>
  19. <indexterm>Docker images</indexterm>
  20. </keywords>
  21. </metadata>
  22. </prolog>
  23. <taskbody>
  24. <section>
  25. <title>About application containers</title>
  26. <p>Using containers to deploy applications isolates software from its environment to ensure that it works
  27. consistently despite any differences in the host operating system, for example.</p>
  28. <p>Docker containers are designed as stateless machines that can be quickly created and destroyed, started and
  29. stopped. Each Docker image provides its own private filesystem that includes only the code required to run the
  30. application itself — it is not intended for persistent data storage.</p>
  31. <p>When a container is stopped, any changes made within the container are lost, so source files and generated
  32. output should be stored outside the container. These resources are attached to the container by mounting
  33. directories from the host machine.</p>
  34. </section>
  35. <prereq>
  36. <p>To run the DITA-OT image, you will need to install Docker and log in to the GitHub Package Registry.
  37. <ul>
  38. <li>To download Docker Desktop, you may be prompted to sign in with your Docker ID (or sign up to create
  39. one).</li>
  40. <li>To retrieve docker images from the GitHub Package Registry, you will also need a GitHub account.</li>
  41. </ul></p>
  42. </prereq>
  43. <steps>
  44. <step>
  45. <cmd>Install Docker for your operating system.</cmd>
  46. <choices>
  47. <choice>
  48. <xref href="https://docs.docker.com/docker-for-windows/install/" scope="external" format="html">Install
  49. Docker Desktop on Windows</xref>
  50. </choice>
  51. <choice>
  52. <xref href="https://docs.docker.com/docker-for-mac/install" scope="external" format="html">Install Docker
  53. Desktop on Mac</xref>
  54. </choice>
  55. <choice>On macOS, you can also install Docker Desktop via
  56. <xref keyref="homebrew"/>:
  57. <codeblock>$ <cmdname>brew</cmdname> cask install docker
  58. <systemoutput>Downloading…</systemoutput></codeblock>
  59. </choice>
  60. <choice>On Linux, install Docker Community Edition (CE) via your operating system’s package manager, for
  61. example: <codeblock>$ <cmdname>sudo</cmdname> apt-get install docker-ce</codeblock></choice>
  62. </choices>
  63. </step>
  64. <step>
  65. <cmd>Log in to the GitHub Package Registry.</cmd>
  66. <substeps>
  67. <substep>
  68. <cmd>In your
  69. <xref href="https://github.com/settings/tokens" format="html" scope="external">GitHub profile
  70. settings</xref>, create a new personal access token with the <codeph>read:packages</codeph> and
  71. <codeph>repo</codeph> scopes.</cmd>
  72. <info>For more information, see
  73. <xref href="https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line"
  74. scope="external" format="html">Creating a personal access token for the command line</xref>.</info>
  75. </substep>
  76. <substep>
  77. <cmd>On the command line, run the <cmdname>docker</cmdname> command to log in with your GitHub
  78. credentials.</cmd>
  79. <stepxmp>
  80. <codeblock><cmdname>docker</cmdname> login docker.pkg.github.com -u <varname>USERNAME</varname> -p <varname>PASSWORD/TOKEN</varname></codeblock>
  81. </stepxmp>
  82. <info>For more information, see
  83. <xref
  84. href="https://help.github.com/en/articles/configuring-docker-for-use-with-github-package-registry#authenticating-to-github-package-registry"
  85. scope="external" format="html">Authenticating to GitHub Package Registry</xref>.</info>
  86. </substep>
  87. </substeps>
  88. </step>
  89. <step>
  90. <cmd>To build output, map a host directory to a container volume and specify options for the
  91. <cmdname>dita</cmdname> command.</cmd>
  92. <stepxmp>
  93. <codeblock>$ <cmdname>docker</cmdname> run -it \
  94. -v /Users/<varname>username</varname>/source:/src docker.pkg.github.com/dita-ot/dita-ot/dita-ot:<keyword keyref="maintenance-version"/> \
  95. -i /src/input.ditamap \
  96. -o /src/out \
  97. -f html5 -v</codeblock>
  98. <p>This command sequence specifies the following options:
  99. <ul>
  100. <li><option>-v</option> mounts the <filepath>source</filepath> subfolder of your home directory and binds
  101. it to the <filepath>/src</filepath> volume in the container</li>
  102. <li><option>-i</option> specifies the <filepath>input.ditamap</filepath> file in your
  103. <filepath>source</filepath> folder as the input map file</li>
  104. <li><option>-o</option> writes the output to <filepath>source/out</filepath></li>
  105. <li><option>-f</option> sets the output format to HTML5, and</li>
  106. <li><option>-v</option> displays build progress messages with verbose logging</li>
  107. </ul>
  108. </p>
  109. <p>On Windows, if your <filepath>Users</filepath> directory is on the <filepath>C:\</filepath> drive, use
  110. <filepath>/c/Users/…</filepath> to map the host directory:</p>
  111. <codeblock>C:\Users\username> <cmdname>docker</cmdname> run -it \
  112. -v /c/Users/<varname>username</varname>/source:/src docker.pkg.github.com/dita-ot/dita-ot/dita-ot:<keyword keyref="maintenance-version"/> \
  113. -i /src/input.ditamap \
  114. -o /src/out \
  115. -f html5 -v</codeblock>
  116. </stepxmp>
  117. <info>
  118. <note>The DITA-OT container image uses the <codeph>ENTRYPOINT</codeph> instruction to run the
  119. <cmdname>dita</cmdname> command from the <filepath>/opt/app/bin/</filepath> directory of the container
  120. automatically, so you there’s no need to include the <cmdname>dita</cmdname> command itself, only the
  121. arguments and options you need to publish your content.</note>
  122. </info>
  123. </step>
  124. </steps>
  125. </taskbody>
  126. </task>