mirror of
https://github.com/pterodactyl/documentation.git
synced 2025-12-10 10:44:43 -06:00
106 lines
36 KiB
HTML
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.9.10">
|
|
<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, 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.894cd3e9.css" as="style"><link rel="preload" href="/assets/js/app.5b33328c.js" as="script"><link rel="preload" href="/assets/js/4.1c05de3a.js" as="script"><link rel="preload" href="/assets/js/2.638bc23b.js" as="script"><link rel="preload" href="/assets/js/32.f259a483.js" as="script"><link rel="prefetch" href="/assets/js/1.364681bc.js"><link rel="prefetch" href="/assets/js/10.85ddee89.js"><link rel="prefetch" href="/assets/js/11.e264572d.js"><link rel="prefetch" href="/assets/js/12.a4261b01.js"><link rel="prefetch" href="/assets/js/13.43a16fbd.js"><link rel="prefetch" href="/assets/js/14.ed610c4a.js"><link rel="prefetch" href="/assets/js/15.954755fc.js"><link rel="prefetch" href="/assets/js/16.80d778f6.js"><link rel="prefetch" href="/assets/js/17.aa66495a.js"><link rel="prefetch" href="/assets/js/18.57b733fd.js"><link rel="prefetch" href="/assets/js/19.ec92bd63.js"><link rel="prefetch" href="/assets/js/20.93f220a6.js"><link rel="prefetch" href="/assets/js/21.d99db7fa.js"><link rel="prefetch" href="/assets/js/22.c4d3c3e7.js"><link rel="prefetch" href="/assets/js/23.4a3e5e0b.js"><link rel="prefetch" href="/assets/js/24.14d17171.js"><link rel="prefetch" href="/assets/js/25.b2ca157b.js"><link rel="prefetch" href="/assets/js/26.55d35d4f.js"><link rel="prefetch" href="/assets/js/27.005f34ff.js"><link rel="prefetch" href="/assets/js/28.a5eb93d2.js"><link rel="prefetch" href="/assets/js/29.173d87c8.js"><link rel="prefetch" href="/assets/js/30.a5e153c0.js"><link rel="prefetch" href="/assets/js/31.bbfc69d7.js"><link rel="prefetch" href="/assets/js/33.27c2a6a4.js"><link rel="prefetch" href="/assets/js/34.e93e5695.js"><link rel="prefetch" href="/assets/js/35.a04be06d.js"><link rel="prefetch" href="/assets/js/36.d63650be.js"><link rel="prefetch" href="/assets/js/37.25a34a1f.js"><link rel="prefetch" href="/assets/js/38.059a51d4.js"><link rel="prefetch" href="/assets/js/39.942d570b.js"><link rel="prefetch" href="/assets/js/40.26972213.js"><link rel="prefetch" href="/assets/js/41.368a213d.js"><link rel="prefetch" href="/assets/js/42.ea03a576.js"><link rel="prefetch" href="/assets/js/43.c024e279.js"><link rel="prefetch" href="/assets/js/44.4b352263.js"><link rel="prefetch" href="/assets/js/45.638b4daf.js"><link rel="prefetch" href="/assets/js/46.b6984e9b.js"><link rel="prefetch" href="/assets/js/47.0f24220f.js"><link rel="prefetch" href="/assets/js/48.c19ab66e.js"><link rel="prefetch" href="/assets/js/49.32b7f82e.js"><link rel="prefetch" href="/assets/js/5.8c798c34.js"><link rel="prefetch" href="/assets/js/50.ee14ad41.js"><link rel="prefetch" href="/assets/js/51.f11b077a.js"><link rel="prefetch" href="/assets/js/52.8e320849.js"><link rel="prefetch" href="/assets/js/53.944dc699.js"><link rel="prefetch" href="/assets/js/54.d6bff428.js"><link rel="prefetch" href="/assets/js/55.a226dbb6.js"><link rel="prefetch" href="/assets/js/56.f682278e.js"><link rel="prefetch" href="/assets/js/57.0ae7168d.js"><link rel="prefetch" href="/assets/js/58.659e70d5.js"><link rel="prefetch" href="/assets/js/59.74ce363c.js"><link rel="prefetch" href="/assets/js/6.cd87a2b3.js"><link rel="prefetch" href="/assets/js/60.ef3d5ede.js"><link rel="prefetch" href="/assets/js/61.d30789b5.js"><link rel="prefetch" href="/assets/js/62.5f19d6a7.js"><link rel="prefetch" href="/assets/js/63.38756aa5.js"><link rel="prefetch" href="/assets/js/64.ec49abec.js"><link rel="prefetch" href="/assets/js/65.61c0bfd2.js"><link rel="prefetch" href="/assets/js/66.9a2707a1.js"><link rel="prefetch" href="/assets/js/67.275f5b02.js"><link rel="prefetch" href="/assets/js/68.66b31eec.js"><link rel="prefetch" href="/assets/js/69.e57354fd.js"><link rel="prefetch" href="/assets/js/7.f17059bf.js"><link rel="prefetch" href="/assets/js/70.cbd191fe.js"><link rel="prefetch" href="/assets/js/71.e6dd244d.js"><link rel="prefetch" href="/assets/js/8.758e7e8b.js"><link rel="prefetch" href="/assets/js/9.90f962cd.js">
|
|
<link rel="stylesheet" href="/assets/css/0.styles.894cd3e9.css">
|
|
</head>
|
|
<body>
|
|
<div id="app" data-server-rendered="true"><div><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">
|
|
GitHub
|
|
<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">
|
|
GitHub
|
|
<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">Enterprise Linux 8 and Fedora Server 40</a></li><li><a href="/community/installation-guides/panel/debian.html" class="sidebar-link">Debian 11 & 12</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">Enterprise Linux 8 and Fedora Server 40</a></li><li><a href="/community/installation-guides/wings/debian.html" class="sidebar-link">Debian 11 & 12</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 & 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 & 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"><</span>support@pterodactyl.io<span class="token operator">></span>
|
|
|
|
RUN apk <span class="token function">add</span> --no-cache <span class="token parameter variable">--update</span> <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">&&</span> adduser --disabled-password <span class="token parameter variable">--home</span> /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">"/bin/bash"</span>, <span class="token string">"/entrypoint.sh"</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 <span class="token parameter variable">-D</span> <span class="token parameter variable">-h</span> /home/container container
|
|
</code></pre></div><div class="custom-block warning"><p class="custom-block-title">WARNING</p> <p>All Pterodactyl containers must have a user named <code>container</code>, and the user home <strong>must</strong> be <code>/home/container</code>.</p></div> <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 & 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">"/bin/bash"</span>, <span class="token string">"/entrypoint.sh"</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>
|
|
<span class="token function">java</span> <span class="token parameter variable">-version</span> <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> <span class="token parameter variable">-e</span> <span class="token string">'s/{{/${/g'</span> <span class="token parameter variable">-e</span> <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">":/home/container$ <span class="token variable">${MODIFIED_STARTUP}</span>"</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">"java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}"</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> <span class="token parameter variable">-e</span> <span class="token string">'s/{{/${/g'</span> <span class="token parameter variable">-e</span> <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><span class="token function">java</span> <span class="token parameter variable">-Xms128M</span> -Xmx<span class="token punctuation">{</span><span class="token punctuation">{</span>SERVER_MEMORY<span class="token punctuation">}</span><span class="token punctuation">}</span>M <span class="token parameter variable">-jar</span> <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><span class="token function">java</span> <span class="token parameter variable">-Xms128M</span> <span class="token parameter variable">-Xmx1024M</span> <span class="token parameter variable">-jar</span> 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><div class="global-ui"></div></div>
|
|
<script src="/assets/js/app.5b33328c.js" defer></script><script src="/assets/js/4.1c05de3a.js" defer></script><script src="/assets/js/2.638bc23b.js" defer></script><script src="/assets/js/32.f259a483.js" defer></script>
|
|
</body>
|
|
</html>
|