Docker container startup
- Last UpdatedSep 30, 2024
- 2 minute read
Docker container startup
The following procedures contain instructions on how to run the adapter inside a Docker container with different options enabled.
Run the Docker container with REST access enabled
To run the adapter inside a Docker container with access to its REST API from the local host, complete the following steps:
-
Use the docker container image <adapter>adapter created previously.
-
Type the following in the command line (sudo may be necessary):
docker run -d --network host <adapter>adapter
Port 5590 is accessible from the host and you can make REST calls to the adapter from applications on the local host computer. In this example, all data stored by the adapter is stored in the container itself. When you delete the container, the stored data is also deleted.
Run the Docker container with persistent storage
To run the adapter inside a Docker container while using the host for persistent storage, complete the following steps. This procedure also enables access to the adapter REST API from the local host.
-
Use the docker container image<adapter>adapter created previously.
-
Type the following in the command line (sudo may be necessary):
docker run -d --network host -v /<adapter>:/usr/share/OSIsoft/<adapter>adapter
Port 5590 is accessible from the host and you can make REST calls to the adapter from applications on the local host computer. In this example, all data that is written to the container is instead written to the host directory and the host directory is a directory on the local machine, /<adapter>. You can specify any directory.
Change port number
To use a different port other than 5590, you can specify a portnum variable on the docker run command line. For example, to start the adapter using port 6000 instead of 5590, use the following command:
docker run -d -e portnum=6000 --network host <adapter>adapter
This command accesses the REST API with port 6000 instead of port 5590. The following curl command returns the configuration for the container.
curl http://localhost:6000/api/v1/configuration
Remove REST access
If you remove the --network host option from the docker run command, REST access is not possible from outside the container. This may be of value where you want to host an application in the same container as the adapter but do not want to have external REST access enabled.