Assigning a public IP to a container
This guide will walk you through the steps of assigning a public IP to a container. This will allow worker node containers to have an IP address that can be used for access from the internet.
![Public IP networking](../_images/public_ip.png)
Step 1: Reserve a worker node
See the “reservation of a worker node” section.
Step 2: Create a container
Here, we connect a container application, running on a worker node, to a public IP. This involves including the container in the “serverpublic” network when starting the container.
From the ExPECA home page, click Container -> Containers
![Containers main page](../_images/container_run1.png)
Click + Create Container
See “Running a basic container” for the steps involved. We will here only focus on the data entered for network connection.
Under “Networks” tab, bring “serverpublic” to the top
Under “Miscellaneous” tab, enter environment variables needed for the container.
Under “Labels” tab, enter a public IP address in the 130.237.11.[113-126]/27 range, as well as the “serverpublic” gateway.
![Containers networks page](../_images/container_run2.png)
![Containers miscellaneous page](../_images/container_run3.png)
![Containers labels page](../_images/container_run4.png)
Click Create
![Containers main page](../_images/container_run5.png)
Note that DNS and default gateway needs to be set for the container. In this case, the container gets this information from environment variables in the “miscellaneous” section, but it is up to the container designer for how this should be done. It can be done either manually through the console, or if they want it done automatically, they can use a container that does such tasks during boot up. To perform those tasks, the container must have ip commands installed. For an ubuntu container, this means the following line must be included in the Dockerfile:
RUN apt update && apt install -y openssh-server iproute2
Then the following commands could be run either manually through the console, or within the container’s entrypoint:
You should now be able to connect with SSH to your container from the internet.
![Container console page](../_images/container_run6.png)