Docker
This page provides installation and configuration information for Docker.
Docker
Confirming Docker is installed correctly
NOTE: Note: Apple M1 devices: At the time of writing there are some issues on Apple M1 devices and, some ARM64/ARMv8 devices. Please review this forum thread before proceeding.
Docker
Run the following command to confirm Docker is installed:
Example Output:
Docker Compose
Docker Compose v1 uses the command docker-compose
. As of June 2023 support ends for Docker Compose v1.
Docker Compose v2 uses the command docker compose
.
If you are using Docker Compose v1 please adjust the commands accoridingly. More infromation on Docker Compose can be found here.
Run one of the following commands to check Docker Compose is installed:
Docker Compose v1:
Docker Compose v2:
Example Output:
A Docker Hello-World
To ensure that Docker has the ability to pull and run container images run the following command:
Example Output:
Installation
Using the pre-built Container
In order to run PowerShell Universal, you can use the provided container image. The docker image is available on Docker Hub .
The prebuilt version allows you to run all free and paid features of PowerShell Universal.
You can start the container by pulling the image and then running a container with the default port bound.
Running a basic image
Present an image to a different port
If port 5000 is unavailable on your host, this can be switched to another port.
e.g. Present on port 80
Mount a volume
The docker run
command will allow you to mount a volume for persistent storage. This needs to be mounted to the /root folder.
Mount a volume on container in Windows
The following command mounts the folder C:\docker\volumes\PSU
to /root
on your container
Mount a volume on Container on Mac and Linux
The following command mounts the folder /docker/volumes/PSU
to /root
on your container
Stopping a Container
The following command removes a stopped container named PSU
Removing a Container
The following command stops a container named PSU
The --force
flag can be used to remove a running container
Docker Compose
Docker Compose allows you to use a yaml text file to standardize your build and script the deployment (or build) or multiple containers.
The default name for any compose file is docker-compose.yml
it is recommended you use this as your compose filename.
Creating a Compose Script for Windows
The following compose file will run a Powershell Universal container in Windows
Creating a Compose Script for Mac / Linux
The following compose file will run a Powershell Universal container on Mac's and Linux
Starting Containers using Compose Scripts
Using a Terminal shell, or PowerShell for Windows. cd to the directory with your docker-compose.yml
script.
Run the following command
Example Output:
Stopping Containers using Compose Scripts
Using a Terminal shell, or PowerShell for Windows. cd to the directory with your docker-compose.yml
script.
Run the following command
Example Output:
Using Environment Variables and SQL Persistance
You can add Environment variables into your Compose Scripts. Below is an example of:
Setting a node name
Adding SQL persistance
Adding a SQL Connection String
Building a Custom Container
In some cases, you may wish to build more features, modify, or hardcode Environment Variables into your container.
For that, you will need to Create a Dockerfile
NOTE: Dockerfiles' are case-sensitive and must start with a capital 'D'.
To create a Docker image that can persist the Universal data, you can create a dockerfile like the one below.
This Dockerfile exposes port 5000, creates a /data volume, sets configuration environment variables to store the Universal repository and database in the volume and then sets the Universal.Server as the entry point to the container.
Writing a Dockerfile script for Linux
Building a container
From the path your Dockerfile is hosted in run the following command:
Windows
You can run a build with the build command.
You can start the docker container with the run command and make sure to specify the volume to mount.
SQL
To use SQL persistence, you can define the plugin and connection string as follows.
Time Zones
To properly support time zones on Linux when scheduling jobs, you will need to include the tzdata
package in your dockerfile along with an environment variable that specifies the server time zone.
Summary
This has been a very basic "How get get started" which allows you to get started running or building PSU Containers. All souces for commands have been linked in the referances session.
References
Running Containers
https://docs.docker.com/engine/reference/commandline/run/
https://docs.docker.com/engine/reference/commandline/stop/
https://docs.docker.com/engine/reference/commandline/rm/
https://docs.docker.com/compose/
Building Containers
https://docs.docker.com/engine/reference/commandline/build/
Last updated