Chapter 2. APIcast on the Docker containerized environment
This is a step-by-step guide to deploy APIcast inside a Docker-formatted container that is ready to be used as a 3scale API gateway.
You must configure APIcast in your 3scale Admin Portal as per the APIcast Overview.
2.2. Step 1: Install the Docker containerized environment
This guide covers the steps to set up the Docker containerized environment on Red Hat Enterprise Linux (RHEL) 7.
Docker-formatted containers provided by Red Hat are released as part of the Extras channel in RHEL. To enable additional repositories, you can use either the Subscription Manager or the yum config manager. For details, see the RHEL product documentation.
To deploy RHEL 7 on an AWS EC2 instance, take the following steps:
List all repositories:
sudo yum repolist all.
sudo yum-config-manager --enable rhui-REGION-rhel-server-extras.
Install the Docker containerized environment package:
sudo yum install docker.
For other operating systems, refer to the following Docker documentation:
2.3. Step 2: Run the Docker containerized environment gateway
Start the Docker daemon:
sudo systemctl start docker.service.
Check if the Docker daemon is running:
sudo systemctl status docker.service.
You can download a ready to use Docker-formatted container image from the Red Hat registry:
sudo docker pull registry.access.redhat.com/3scale-amp24/apicast-gateway.
Run APIcast in a Docker-formatted container:
sudo docker run --name apicast --rm -p 8080:8080 -e THREESCALE_PORTAL_ENDPOINT=https://<access_token>@<domain>-admin.3scale.net registry.access.redhat.com/3scale-amp24/apicast-gateway.
<access_token>is the Access Token for the 3scale Account Management API. You can use the the Provider Key instead of the access token.
<domain>-admin.3scale.netis the URL of your 3scale admin portal.
This command runs a Docker-formatted container called "apicast" on port
8080 and fetches the JSON configuration file from your 3scale portal. For other configuration options, see the APIcast Overview guide.
2.3.1. The Docker command options
You can use the following options with the
docker run command:
--rm: Automatically removes the container when it exits.
--detach: Runs the container in the background and prints the container ID. When it is not specified, the container runs in the foreground mode and you can stop it using
CTRL + c. When started in the detached mode, you can reattach to the container with the
docker attachcommand, for example,
docker attach apicast.
--publish: Publishes a container’s port to the host. The value should have the format
<host port="">:<container port="">, so
-p 80:8080will bind port
8080of the container to port
80of the host machine. For example, the Management API uses port
8090, so you may want to publish this port by adding
-p 8090:8090to the
--env: Sets environment variables.
--volume: Mounts a volume. The value is typically represented as
<host path="">:<container path="">[:<options>].
<options>is an optional attribute; you can set it to
:roto specify that the volume will be read only (by default, it is mounted in read-write mode). Example:
For more information on available options, see Docker run reference.
2.4. Step 3: Testing APIcast
The preceding steps ensure that your Docker-formatted container is running with your own configuration file and the Docker-formatted image from the 3scale registry. You can test calls through APIcast on port
8080 and provide the correct authentication credentials, which you can get from your 3scale account.
Test calls will not only verify that APIcast is running correctly but also that authentication and reporting is being handled successfully.
Ensure that the host you use for the calls is the same as the one configured in the Public Base URL field on the Integration page.
2.5. Step 4: Troubleshooting APIcast on the Docker containerized environment
2.5.1. Cannot connect to the Docker daemon error
The docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host? error message may be because the Docker service hasn’t started. You can check the status of the Docker daemon by running the
sudo systemctl status docker.service command.
Ensure that you are run this command as the
root user because the Docker containerized environment requires root permissions in RHEL by default. For more information, see here).
2.5.2. Basic Docker command-line interface commands
If you started the container in the detached mode (
-d option) and want to check the logs for the running APIcast instance, you can use the
sudo docker logs <container>. Where ,
<container> is the container name ("apicast" in the example above) or the container ID. You can get a list of the running containers and their IDs and names by using the
sudo docker ps command.
To stop the container, run the
sudo docker stop <container> command. You can also remove the container by running the
sudo docker rm <container> command.
For more information on available commands, see Docker commands reference.