ServerAvatarDocs
Applications

Container and Compose

Change a Docker application's image registry, network, port, limits and volumes, pull a fresh image, and edit its compose file.

A Docker application runs in a container. Open the application, then use two items in its sidebar, under Website:

  • Container: the settings the container runs with. The screen says "The network, ports, CPU and memory limits and volumes this container runs with."
  • Compose file: the file that defines the container. The screen says "Image, ports, volumes and environment variables for this application all live in this file."

Only Docker applications have them: one-click Docker apps and apps you create from an image or a compose file. For any other type the screens say "Only Docker applications have a container." and "Only Docker applications have a compose file." To create a Docker application, see Create an application.

Almost every change recreates the container, so the application is down for a few seconds.

Pull a fresh image

The card Image shows the image the application runs, or "No image recorded". It cannot be edited on this screen: a bad reference would fail after the old container is gone. To use another image, edit the compose file.

  1. On Container, select Pull and redeploy.
  2. The button shows Pulling and redeploying… and the card says "Downloading the image and recreating the container. It keeps running if you leave this page." You see "Pull and redeploy started. This page updates when it's done."
  3. When it ends you see "The image was pulled and the container recreated."

While one is running another cannot start: "A Pull and redeploy is running. Wait until it finishes." A failed one is shown on the card: "The last Pull and redeploy failed: reason" with "Reference: code", or "The image could not be pulled."

Pull a private image

  1. On the card Image, open Registry. The choices are None — pull anonymously and each stored credential as name — registry.
  2. Choose the credential and select Save registry.

If the server has no stored credentials, only public images can be pulled: "No registry credentials are stored on this server, so only public images can be pulled." A link, "Add one under Integrations → Docker Registries.", opens the server's registries. If the credential you used was deleted, the choice reads Deleted credential — this application's next pull will be anonymous.

Change the network, port and limits

The card Network and limits holds these fields. Select Save container settings when you are done. The card warns "Saving recreates the container, so the application is down for a few seconds." and then you see "Container settings saved."

  • Network: Its own network (no other application on it), or a network of the server. "Containers on the same network reach each other by name." Another container on the same network reaches this application by the hostname shown under How other containers reach this application, for example http://name. A server with no networks of its own says so and links to "Create a network on the Docker page." If the application's network no longer exists, the card says This network is gone and the container will not start until you pick one that exists. When you move the application to another network, the option Remove the app's old network (name) lets you remove the one Docker made for it. Untick it to keep it.
  • Container port: the port your application listens on inside the container, from 1 to 65535. It is not a port of the server. When the image says it uses another port, the field says "The image uses port n. A different port may make your domain show an error page." and Use n fills it in.
  • Memory limit: for example 512m or 2g. A bare number is bytes, not megabytes. Empty uses the server's default.
  • CPU limit: in cores, for example 0.5, up to what the server has. Empty means no limit.

"Both are ceilings, not reservations: over memory the container is killed and restarted; over CPU it just runs slow."

Volumes

The card Volumes lists what is mounted into the container. Without volumes it says "No volumes. Nothing in this container survives a rebuild." Each change here is saved at once and recreates the container: "Mounting a volume restarts the container, and the path starts empty."

  1. Under Choose a volume, pick a volume of the server. One that is already mounted shows "(already mounted)".
  2. Enter the Path inside the container, for example /var/lib/mysql.
  3. Select Mount. You see "volume mounted. The container was recreated."

To remove one, select Unmount volume. A server with no volumes says "This server has no volumes yet, so there is nothing to mount." and links to "Create a volume on the Docker page."

Generated credentials

An application that ServerAvatar created with its own credentials, such as an admin password, shows the card Generated credentials. Select Reveal to read them and the copy buttons to copy them. "Created when the app was installed, and stored encrypted. Revealing them is recorded in the activity log." You cannot change them here: "The app stores them itself, so changing one here is not possible — the app would keep the old value." The first time, the Overview shows them under Save these credentials now until you select I've saved these. See Read the overview.

Edit the compose file

Compose file opens the file the container runs, in an editor.

  1. Open Compose file. The editor lists what is checked: "Checked by Docker before it runs", "Ports open on this server only — visitors reach the app through its domain" and "Mounts stay inside this application's folder".
  2. Passwords, keys and tokens in the file are hidden, and the file can't be edited until you select Reveal to edit. "Revealing them is recorded in the activity log."
  3. Edit the file. Revert undoes your changes, Copy copies the file, and "Unsaved changes" shows while it differs from what is saved.
  4. If ServerAvatar generated the file, tick "I understand that saving replaces the generated file permanently." The screen warns "Saving here means this file runs, and the settings on the Container page stop driving it."
  5. Select Save and apply. "Saving restarts the container, so the application is briefly down. If the new file won't start, ServerAvatar puts the previous one back." You see "The compose file was applied and the container recreated."

After you save your own file, the Container screen shows the card Set in the compose file: "This application runs its own compose file, so its port, memory and CPU limits, network and volumes are changed there, not here." It links to Open the compose file. A one-click app still takes its memory and CPU limits on Container under Memory and CPU: "Limits for this application's own container. Its database keeps its own limit."

On the Overview

A Docker application's Overview has two more cards for its container:

  • Command-line access: "Open a shell in this application's container over SSH." It runs as the application's system user. To turn it on, use the form Turn on container login for user: "Logging in as user will open this app's container directly." Either Add your SSH key (recommended, no password prompt) or Set a password, tick "I understand that user will log in to this container only" and select Turn on container login. After this, that user's SSH login opens this container only, and normal SSH and SFTP for it stop. For normal server SSH, create a separate system user. The card then shows the commands to Open a shell in the container, Run one command and View logs. Turn off switches it off again.
  • The container isn't answering (or The container keeps restarting): "Fix the cause, then deploy again. The application shows an error until then." It shows the last log lines and the actions that apply: Use port n when the image's port differs, Change port, Edit environment variables, View full logs and Redeploy. After a redeploy it waits for the app to answer, "This can take up to a minute and a half." and then says "The container is answering now." or "It still isn't answering."

Limits

  • Container port: 1 to 65535.
  • Memory limit: up to 20 characters, a number with an optional b, k, m or g.
  • CPU limit: up to 16 characters, a number above 0 with at most two decimals.
  • Volumes: up to 20 mounts. The path is absolute, up to 255 characters, on one line and without ...
  • The compose file: up to 131,072 characters (128 KB), and it cannot be empty.

Who can do this

  • Seeing Container needs View on Container (application.container). Saving settings, Pull and redeploy, volumes and Reveal need Manage. With view only the fields are read-only: "You don't have permission to change this application."
  • Choosing a registry also needs View on the server's Docker registries (server.integrations.registry).
  • Compose file and the Command-line access card need View on Compose File (application.compose). Saving the file needs Manage.
  • Turning container login on or off needs Manage on System Users (server.system-user). Without it the card says "Ask an admin to turn on container login for user."
  • Container and Compose File can be given in a server share.
  • Changes and every look at the credentials are recorded in the server's activity log, never with a password, a key or the file. See Application activity.

Common errors

  • Only Docker applications have a container. / Only Docker applications have a compose file. The application is not a Docker application.
  • You don't have access to this application's container. / ...compose file. Ask an owner for view access.
  • Couldn't save the container settings. The server did not accept the values. The message under the field says why.
  • The compose file could not be read. Reload the page. The editor does not open on a file it could not read, so an empty file is never saved over a working one.
  • The compose file could not be applied. The new file did not start. The previous one was put back.
  • The file can't be empty. Write the whole file.
  • Pick a volume and give an absolute path inside the container, for example /var/lib/mysql. Fix the mount.
  • Couldn't change the mounts. The server did not accept the mount.

On this page