documentation/community/config/eggs/creating_a_custom_image.html
2021-08-16 07:53:51 +00:00

106 lines
36 KiB
HTML

<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Creating a Custom Docker Image | Pterodactyl</title>
<meta name="generator" content="VuePress 1.8.2">
<link rel="apple-touch-icon" sizes="180x180" href="/favicons/apple-touch-icon.png">
<link rel="icon" type="image/png" href="/favicons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/favicons/favicon-16x16.png" sizes="16x16">
<link rel="mask-icon" href="/favicons/safari-pinned-tab.svg" color="#0e4688">
<link rel="manifest" href="/favicons/site.webmanifest">
<link rel="shortcut icon" href="/favicons/favicon.ico">
<meta name="description" content="Pterodactyl is an open-source game server management panel built with PHP 7, React, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to end users.">
<meta name="msapplication-config" content="/favicons/browserconfig.xml">
<meta name="theme-color" content="#0e4688">
<link rel="preload" href="/assets/css/0.styles.b4cb0fef.css" as="style"><link rel="preload" href="/assets/js/app.0f8fa08b.js" as="script"><link rel="preload" href="/assets/js/4.bff5ff58.js" as="script"><link rel="preload" href="/assets/js/1.79a56ae5.js" as="script"><link rel="preload" href="/assets/js/32.7effab83.js" as="script"><link rel="prefetch" href="/assets/js/10.27cec751.js"><link rel="prefetch" href="/assets/js/11.27ba30b0.js"><link rel="prefetch" href="/assets/js/12.2e01246c.js"><link rel="prefetch" href="/assets/js/13.bd04c4ec.js"><link rel="prefetch" href="/assets/js/14.f2be742e.js"><link rel="prefetch" href="/assets/js/15.a6802091.js"><link rel="prefetch" href="/assets/js/16.f2dea920.js"><link rel="prefetch" href="/assets/js/17.e3b378b0.js"><link rel="prefetch" href="/assets/js/18.fcb158a9.js"><link rel="prefetch" href="/assets/js/19.e107de31.js"><link rel="prefetch" href="/assets/js/2.21e1a937.js"><link rel="prefetch" href="/assets/js/20.a31cd600.js"><link rel="prefetch" href="/assets/js/21.986dab58.js"><link rel="prefetch" href="/assets/js/22.01e99816.js"><link rel="prefetch" href="/assets/js/23.ab477db3.js"><link rel="prefetch" href="/assets/js/24.3db401dc.js"><link rel="prefetch" href="/assets/js/25.fb19183c.js"><link rel="prefetch" href="/assets/js/26.199e42e5.js"><link rel="prefetch" href="/assets/js/27.53b2955f.js"><link rel="prefetch" href="/assets/js/28.b1cca863.js"><link rel="prefetch" href="/assets/js/29.c234f3e0.js"><link rel="prefetch" href="/assets/js/30.61a90133.js"><link rel="prefetch" href="/assets/js/31.6cbb938e.js"><link rel="prefetch" href="/assets/js/33.5cb72a20.js"><link rel="prefetch" href="/assets/js/34.f044669f.js"><link rel="prefetch" href="/assets/js/35.6b4fc97c.js"><link rel="prefetch" href="/assets/js/36.33b7916b.js"><link rel="prefetch" href="/assets/js/37.b81f7a4e.js"><link rel="prefetch" href="/assets/js/38.46b66006.js"><link rel="prefetch" href="/assets/js/39.a7036ff5.js"><link rel="prefetch" href="/assets/js/40.5561e292.js"><link rel="prefetch" href="/assets/js/41.8357cc2d.js"><link rel="prefetch" href="/assets/js/42.96d1acb1.js"><link rel="prefetch" href="/assets/js/43.9fd714d5.js"><link rel="prefetch" href="/assets/js/44.5250ac95.js"><link rel="prefetch" href="/assets/js/45.3ebbab0e.js"><link rel="prefetch" href="/assets/js/46.a3168226.js"><link rel="prefetch" href="/assets/js/47.7a0c0c49.js"><link rel="prefetch" href="/assets/js/48.8b4df094.js"><link rel="prefetch" href="/assets/js/49.1e699f40.js"><link rel="prefetch" href="/assets/js/5.407df260.js"><link rel="prefetch" href="/assets/js/50.fb545b0b.js"><link rel="prefetch" href="/assets/js/51.8bf819d3.js"><link rel="prefetch" href="/assets/js/52.c0fa38e2.js"><link rel="prefetch" href="/assets/js/53.acaa8c4b.js"><link rel="prefetch" href="/assets/js/54.01f718b6.js"><link rel="prefetch" href="/assets/js/55.0c83194a.js"><link rel="prefetch" href="/assets/js/56.488f03fe.js"><link rel="prefetch" href="/assets/js/57.6cdf7d48.js"><link rel="prefetch" href="/assets/js/58.139108d1.js"><link rel="prefetch" href="/assets/js/59.2de63e9e.js"><link rel="prefetch" href="/assets/js/6.8999fd8a.js"><link rel="prefetch" href="/assets/js/60.a35a1994.js"><link rel="prefetch" href="/assets/js/61.c644eb6e.js"><link rel="prefetch" href="/assets/js/62.6d624b0b.js"><link rel="prefetch" href="/assets/js/63.08f06847.js"><link rel="prefetch" href="/assets/js/64.8d69a757.js"><link rel="prefetch" href="/assets/js/65.f54c400d.js"><link rel="prefetch" href="/assets/js/66.840c5fe3.js"><link rel="prefetch" href="/assets/js/67.4ddb259b.js"><link rel="prefetch" href="/assets/js/68.e7498700.js"><link rel="prefetch" href="/assets/js/69.bb730956.js"><link rel="prefetch" href="/assets/js/7.9f1ce256.js"><link rel="prefetch" href="/assets/js/70.758932ef.js"><link rel="prefetch" href="/assets/js/71.f847d74c.js"><link rel="prefetch" href="/assets/js/72.7f5dd9c7.js"><link rel="prefetch" href="/assets/js/73.3c0e5aad.js"><link rel="prefetch" href="/assets/js/74.1351a3ef.js"><link rel="prefetch" href="/assets/js/75.ea6dcba3.js"><link rel="prefetch" href="/assets/js/76.0b5f8895.js"><link rel="prefetch" href="/assets/js/77.54ccbb7a.js"><link rel="prefetch" href="/assets/js/78.a19a3b30.js"><link rel="prefetch" href="/assets/js/8.c1f22b35.js"><link rel="prefetch" href="/assets/js/9.7af626f7.js">
<link rel="stylesheet" href="/assets/css/0.styles.b4cb0fef.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="nav"><div class="sidebar-button block md:hidden flex-no-shrink"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <div class="logo-container"><a href="/" class="home-link router-link-active"><img src="/logos/pterry.svg" class="logo"> <span class="site-name hidden md:inline can-hide">Pterodactyl</span></a></div> <div class="w-full"><div class="flex"><div class="search-box"><input aria-label="Search" placeholder="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links flex-no-shrink hidden md:flex"><div class="nav-item"><a href="/project/introduction.html" class="nav-link">Documentation
</a></div><div class="nav-item"><a href="/community/about.html" class="nav-link">Community Guides
</a></div><div class="nav-item"><a href="https://discord.gg/pterodactyl" target="_blank" rel="noopener noreferrer" class="nav-link external">
Get Help
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://dashflo.net/docs/api/pterodactyl/v1/" target="_blank" rel="noopener noreferrer" class="nav-link external">
API
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <div class="nav-item"><a href="https://github.com/pterodactyl/panel" target="_blank" rel="noopener noreferrer" class="nav-link">
Contribute
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div></nav></div></div></header> <div class="sidebar-mask"></div> <div class="sidebar"><nav class="nav-links flex-no-shrink block md:hidden"><div class="nav-item"><a href="/project/introduction.html" class="nav-link">Documentation
</a></div><div class="nav-item"><a href="/community/about.html" class="nav-link">Community Guides
</a></div><div class="nav-item"><a href="https://discord.gg/pterodactyl" target="_blank" rel="noopener noreferrer" class="nav-link external">
Get Help
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://dashflo.net/docs/api/pterodactyl/v1/" target="_blank" rel="noopener noreferrer" class="nav-link external">
API
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <div class="nav-item"><a href="https://github.com/pterodactyl/panel" target="_blank" rel="noopener noreferrer" class="nav-link">
Contribute
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div></nav> <ul class="sidebar-links"><li><div class="sidebar-group first"><p class="sidebar-heading"><span>Community Guides</span> <!----> <!----></p> <ul class="sidebar-group-items"><li><a href="/community/about.html" class="sidebar-link">Community Guides and Tutorials</a></li></ul></div></li><li><div class="sidebar-group"><p class="sidebar-heading"><span>Panel Installation</span> <!----> <!----></p> <ul class="sidebar-group-items"><li><a href="/community/installation-guides/panel/centos7.html" class="sidebar-link">CentOS 7</a></li><li><a href="/community/installation-guides/panel/centos8.html" class="sidebar-link">CentOS 8, Rocky Linux 8, AlmaLinux 8</a></li><li><a href="/community/installation-guides/panel/debian9.html" class="sidebar-link">Debian 9</a></li><li><a href="/community/installation-guides/panel/debian10.html" class="sidebar-link">Debian 10</a></li><li><a href="/community/installation-guides/panel/ubuntu1804.html" class="sidebar-link">Ubuntu 18.04</a></li><li><a href="/community/installation-guides/panel/ubuntu2004.html" class="sidebar-link">Ubuntu 20.04</a></li></ul></div></li><li><div class="sidebar-group"><p class="sidebar-heading"><span>Wings Installation</span> <!----> <!----></p> <ul class="sidebar-group-items"><li><a href="/community/installation-guides/wings/centos7.html" class="sidebar-link">CentOS 7</a></li><li><a href="/community/installation-guides/wings/centos8.html" class="sidebar-link">CentOS 8, Rocky Linux 8, AlmaLinux 8</a></li><li><a href="/community/installation-guides/wings/debian9.html" class="sidebar-link">Debian 9</a></li><li><a href="/community/installation-guides/wings/debian10.html" class="sidebar-link">Debian 10</a></li><li><a href="/community/installation-guides/wings/ubuntu1804.html" class="sidebar-link">Ubuntu 18.04</a></li><li><a href="/community/installation-guides/wings/ubuntu2004.html" class="sidebar-link">Ubuntu 20.04</a></li></ul></div></li><li><div class="sidebar-group"><p class="sidebar-heading open"><span>Creating Eggs</span> <!----> <!----></p> <ul class="sidebar-group-items"><li><a href="/community/config/eggs/creating_a_custom_egg.html" class="sidebar-link">Creating a Custom Egg</a></li><li><a href="/community/config/eggs/creating_a_custom_image.html" aria-current="page" class="active sidebar-link">Creating a Custom Docker Image</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/community/config/eggs/creating_a_custom_image.html#creating-the-dockerfile" class="sidebar-link">Creating the Dockerfile</a></li><li class="sidebar-sub-header"><a href="/community/config/eggs/creating_a_custom_image.html#installing-dependencies" class="sidebar-link">Installing Dependencies</a></li><li class="sidebar-sub-header"><a href="/community/config/eggs/creating_a_custom_image.html#creating-a-container-user" class="sidebar-link">Creating a Container User</a></li><li class="sidebar-sub-header"><a href="/community/config/eggs/creating_a_custom_image.html#work-directory-entrypoint" class="sidebar-link">Work Directory &amp; Entrypoint</a></li><li class="sidebar-sub-header"><a href="/community/config/eggs/creating_a_custom_image.html#entrypoint-script" class="sidebar-link">Entrypoint Script</a></li><li class="sidebar-sub-header"><a href="/community/config/eggs/creating_a_custom_image.html#modifying-the-startup-command" class="sidebar-link">Modifying the Startup Command</a></li><li class="sidebar-sub-header"><a href="/community/config/eggs/creating_a_custom_image.html#run-the-command" class="sidebar-link">Run the Command</a></li></ul></li></ul></div></li><li><div class="sidebar-group"><p class="sidebar-heading"><span>Game Configuration</span> <!----> <!----></p> <ul class="sidebar-group-items"><li><a href="/community/games/minecraft.html" class="sidebar-link">Minecraft</a></li></ul></div></li><li><div class="sidebar-group"><p class="sidebar-heading"><span>Tutorials</span> <!----> <!----></p> <ul class="sidebar-group-items"><li><a href="/community/config/nodes/add_node.html" class="sidebar-link">Creating a New Node</a></li><li><a href="/community/tutorials/artisan.html" class="sidebar-link">Artisan CLI</a></li></ul></div></li><li><div class="sidebar-group"><p class="sidebar-heading"><span>Customization</span> <!----> <!----></p> <ul class="sidebar-group-items"><li><a href="/community/customization/panel.html" class="sidebar-link">Building Panel Assets</a></li><li><a href="/community/customization/wings.html" class="sidebar-link">Building Wings</a></li></ul></div></li></ul> </div> <div class="page"> <div class="content content__default"><h1 id="creating-a-custom-docker-image"><a href="#creating-a-custom-docker-image" class="header-anchor">#</a> Creating a Custom Docker Image</h1> <p></p><div class="table-of-contents"><ul><li><a href="#creating-the-dockerfile">Creating the Dockerfile</a></li><li><a href="#installing-dependencies">Installing Dependencies</a></li><li><a href="#creating-a-container-user">Creating a Container User</a></li><li><a href="#work-directory-entrypoint">Work Directory &amp; Entrypoint</a></li><li><a href="#entrypoint-script">Entrypoint Script</a></li><li><a href="#modifying-the-startup-command">Modifying the Startup Command</a></li><li><a href="#run-the-command">Run the Command</a><ul><li><a href="#note">Note</a></li></ul></li></ul></div><p></p> <div class="custom-block warning"><p class="custom-block-title">WARNING</p> <p>This tutorial uses examples from our <a href="https://github.com/pterodactyl/images/tree/java" target="_blank" rel="noopener noreferrer"><code>core:java</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> docker image,
which can be found on GitHub. This tutorial also assumes some knowledge of <a href="https://docker.io/" target="_blank" rel="noopener noreferrer">Docker<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>, we suggest
reading up if this all looks foreign to you.</p></div> <h2 id="creating-the-dockerfile"><a href="#creating-the-dockerfile" class="header-anchor">#</a> Creating the Dockerfile</h2> <p>The most important part of this process is to create the <a href="https://docs.docker.com/engine/reference/builder/" target="_blank" rel="noopener noreferrer"><code>Dockerfile</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>
that will be used by the Daemon. Due to heavy restrictions on server containers, you must setup this file in a specific manner.</p> <p>We try to make use of <a href="https://alpinelinux.org" target="_blank" rel="noopener noreferrer">Alpine Linux<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> as much as possible for our images in order to keep their size down.</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># ----------------------------------</span>
<span class="token comment"># Pterodactyl Core Dockerfile</span>
<span class="token comment"># Environment: Java</span>
<span class="token comment"># Minimum Panel Version: 0.6.0</span>
<span class="token comment"># ----------------------------------</span>
FROM openjdk:8-jdk-alpine
MAINTAINER Pterodactyl Software, <span class="token operator">&lt;</span>support@pterodactyl.io<span class="token operator">&gt;</span>
RUN apk <span class="token function">add</span> --no-cache --update <span class="token function">curl</span> ca-certificates openssl <span class="token function">git</span> <span class="token function">tar</span> <span class="token function">bash</span> sqlite fontconfig <span class="token punctuation">\</span>
<span class="token operator">&amp;&amp;</span> adduser --disabled-password --home /home/container container
<span class="token environment constant">USER</span> container
ENV <span class="token assign-left variable"><span class="token environment constant">USER</span></span><span class="token operator">=</span>container <span class="token assign-left variable"><span class="token environment constant">HOME</span></span><span class="token operator">=</span>/home/container
WORKDIR /home/container
COPY ./entrypoint.sh /entrypoint.sh
CMD <span class="token punctuation">[</span><span class="token string">&quot;/bin/bash&quot;</span>, <span class="token string">&quot;/entrypoint.sh&quot;</span><span class="token punctuation">]</span>
</code></pre></div><p>Lets walk through the <code>Dockerfile</code> above. The first thing you'll notice is the <a href="https://docs.docker.com/engine/reference/builder/#from" target="_blank" rel="noopener noreferrer"><code>FROM</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> declaration.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>FROM openjdk:8-jdk-alpine
</code></pre></div><p>In this case, we are using <a href="https://github.com/docker-library/openjdk" target="_blank" rel="noopener noreferrer"><code>openjdk:8-jdk-alpine</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> which provides us with Java 8.</p> <h2 id="installing-dependencies"><a href="#installing-dependencies" class="header-anchor">#</a> Installing Dependencies</h2> <p>The next thing we do is install the dependencies we will need using Alpine's package manager: <code>apk</code>. You'll notice some
specific flags that keep the container small, including <code>--no-cache</code>, as well as everything being contained in a
single <a href="https://docs.docker.com/engine/reference/builder/#run" target="_blank" rel="noopener noreferrer"><code>RUN</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> block.</p> <h2 id="creating-a-container-user"><a href="#creating-a-container-user" class="header-anchor">#</a> Creating a Container User</h2> <p>Within this <code>RUN</code> block, you'll notice the <code>useradd</code> command.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>adduser -D -h /home/container container
</code></pre></div><p class="callout warning">All Pterodactyl containers must have a user named `container`, and the user home **must** be `/home/container`.</p> <p>After we create that user, we then define the default container <a href="https://docs.docker.com/engine/reference/builder/#user" target="_blank" rel="noopener noreferrer"><code>USER</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>
as well as a few <a href="https://docs.docker.com/engine/reference/builder/#env" target="_blank" rel="noopener noreferrer"><code>ENV</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> settings to be applied to things running
within the container.</p> <h2 id="work-directory-entrypoint"><a href="#work-directory-entrypoint" class="header-anchor">#</a> Work Directory &amp; Entrypoint</h2> <p>One of the last things we do is define a <a href="https://docs.docker.com/engine/reference/builder/#workdir" target="_blank" rel="noopener noreferrer"><code>WORKDIR</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> which
is where everything else will be executed. The <code>WORKDIR</code> must be set the <code>/home/container</code>.</p> <p>Finally, we need to copy our <a href="https://docs.docker.com/engine/reference/builder/#entrypoint" target="_blank" rel="noopener noreferrer"><code>ENTRYPOINT</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> script into
the docker image root. This is done using <a href="https://docs.docker.com/engine/reference/builder/#copy" target="_blank" rel="noopener noreferrer"><code>COPY</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>, after which
we define the command to be used when the container is started using <a href="https://docs.docker.com/engine/reference/builder/#cmd" target="_blank" rel="noopener noreferrer"><code>CMD</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.
The <code>CMD</code> line should always point to the <code>entrypoint.sh</code> file.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>COPY ./entrypoint.sh /entrypoint.sh
CMD <span class="token punctuation">[</span><span class="token string">&quot;/bin/bash&quot;</span>, <span class="token string">&quot;/entrypoint.sh&quot;</span><span class="token punctuation">]</span>
</code></pre></div><h2 id="entrypoint-script"><a href="#entrypoint-script" class="header-anchor">#</a> Entrypoint Script</h2> <p>In order to complete this <code>Dockerfile</code>, we will need an <code>entrypoint.sh</code> file which tells Docker how to run this
specific server type.</p> <p>These entrypoint files are actually fairly abstracted, and the Daemon will pass in the start command as an environment
variable before processing it and then executing the command.</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token shebang important">#!/bin/bash</span>
<span class="token builtin class-name">cd</span> /home/container
<span class="token comment"># Output Current Java Version</span>
java -version <span class="token comment">## only really needed to show what version is being used. Should be changed for different applications</span>
<span class="token comment"># Replace Startup Variables</span>
<span class="token assign-left variable">MODIFIED_STARTUP</span><span class="token operator">=</span><span class="token variable"><span class="token variable">`</span><span class="token builtin class-name">eval</span> <span class="token builtin class-name">echo</span> <span class="token punctuation">$(</span>echo $<span class="token punctuation">{</span>STARTUP<span class="token punctuation">}</span> <span class="token operator">|</span> <span class="token function">sed</span> -e <span class="token string">'s/{{/${/g'</span> -e <span class="token string">'s/}}/}/g'</span><span class="token punctuation">)</span><span class="token variable">`</span></span>
<span class="token builtin class-name">echo</span> <span class="token string">&quot;:/home/container$ <span class="token variable">${MODIFIED_STARTUP}</span>&quot;</span>
<span class="token comment"># Run the Server</span>
<span class="token variable">${MODIFIED_STARTUP}</span>
</code></pre></div><p>The second command, <code>cd /home/container</code>, simply ensures we are in the correct directory when running the rest of the
commands. We then follow that up with <code>java -version</code> to output this information to end-users, but that is not necessary.</p> <h2 id="modifying-the-startup-command"><a href="#modifying-the-startup-command" class="header-anchor">#</a> Modifying the Startup Command</h2> <p>The most significant part of this file is the <code>MODIFIED_STARTUP</code> environment variable. What we are doing in this case
is parsing the environment <code>STARTUP</code> that is passed into the container by the Daemon. In most cases, this variable
looks something like the example below:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token assign-left variable">STARTUP</span><span class="token operator">=</span><span class="token string">&quot;java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}&quot;</span>
</code></pre></div><div><p>You'll notice some placeholders there, specifically <code>{{SERVER_MEMORY}}</code> and <code>{{SERVER_JARFILE}}</code>. These both refer to
other environment variables being passed in, and they look something like the example below.</p></div><div class="language-bash extra-class"><pre class="language-bash"><code><span class="token assign-left variable">SERVER_MEMORY</span><span class="token operator">=</span><span class="token number">1024</span>
<span class="token assign-left variable">SERVER_JARFILE</span><span class="token operator">=</span>server.jar
</code></pre></div><p>There are a host of different environment variables, and they change depending on the specific service option
configuration. However, that is not necessarily anything to worry about here.</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token assign-left variable">MODIFIED_STARTUP</span><span class="token operator">=</span><span class="token variable"><span class="token variable">`</span><span class="token builtin class-name">eval</span> <span class="token builtin class-name">echo</span> <span class="token punctuation">$(</span>echo $<span class="token punctuation">{</span>STARTUP<span class="token punctuation">}</span> <span class="token operator">|</span> <span class="token function">sed</span> -e <span class="token string">'s/{{/${/g'</span> -e <span class="token string">'s/}}/}/g'</span><span class="token punctuation">)</span><span class="token variable">`</span></span>
</code></pre></div><div><p>The command above simply evaluates the <code>STARTUP</code> environment variable, and then replaces anything surrounded in
curly braces <code>{{EXAMPLE}}</code> with a matching environment variable (such as <code>EXAMPLE</code>). Thus, our <code>STARTUP</code> command:</p></div><div class="language-bash extra-class"><pre class="language-bash"><code>java -Xms128M -Xmx<span class="token punctuation">{</span><span class="token punctuation">{</span>SERVER_MEMORY<span class="token punctuation">}</span><span class="token punctuation">}</span>M -jar <span class="token punctuation">{</span><span class="token punctuation">{</span>SERVER_JARFILE<span class="token punctuation">}</span><span class="token punctuation">}</span>
</code></pre></div><p>Becomes:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>java -Xms128M -Xmx1024M -jar server.jar
</code></pre></div><h2 id="run-the-command"><a href="#run-the-command" class="header-anchor">#</a> Run the Command</h2> <p>The last step is to run this modified startup command, which is done with the line <code>${MODIFIED_STARTUP}</code>.</p> <h3 id="note"><a href="#note" class="header-anchor">#</a> Note</h3> <p>Sometimes you may need to change the permissions of the <code>entrypoint.sh</code> file, on linux you can do this by executing <code>chmod +x entrypoint.sh</code> in the directory where the file is.</p></div> <div class="page-edit"><div class="edit-link"><a href="https://github.com/pterodactyl/documentation/edit/master/community/config/eggs/creating_a_custom_image.md" target="_blank" rel="noopener noreferrer">Help us improve this page.</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <!----></div> <div class="page-nav"><p class="inner"></p> <div class="prev"><span>
<a href="/community/config/eggs/creating_a_custom_egg.html">Creating a Custom Egg</a></span></div> <div class="next"><span><a href="/community/games/minecraft.html">Minecraft</a>
</span></div></div> </div></div><div class="global-ui"></div></div>
<script src="/assets/js/app.0f8fa08b.js" defer></script><script src="/assets/js/4.bff5ff58.js" defer></script><script src="/assets/js/1.79a56ae5.js" defer></script><script src="/assets/js/32.7effab83.js" defer></script>
</body>
</html>