How do I run AMPS in a Docker container?

The 60East engineering team has used Docker with AMPS for our own internal testing, but we have stopped short of recommending it or providing extensive documentation how to use Docker. In our experience, the performance of the Docker network bridge/NAT layer that used by default isn't really suitable for the kinds of apps most people want to build with AMPS.

Having said that, if you want to use Docker with AMPS for development purposes, it's not hard to do.

Here's a short guide:

1. Create a file called Dockerfile in the same directory with an AMPS configuration file (config.xml) that you want to use:

FROM ubuntu 
MAINTAINER 60East Technologies <support@crankuptheamps.com> 
ADD <link-to-AMPS-distribution-archive> /binaries/AMPS.tar
COPY config.xml / 
RUN ls -l / 
RUN ls -l /binaries 
RUN tar xvf /binaries/AMPS.tar --transform='s,AMPS[^/]*/,AMPS/,' 
RUN ls -l / 
 
# expose websocket and TCP port (adjust as needed for your AMPS config file)
EXPOSE 9007 
EXPOSE 9008 
 
# expose Admin port (adjust as needed for your AMPS config file)
EXPOSE 8085 
 
CMD ["/AMPS/bin/ampServer","config.xml"] 

Notice that in the ADD instruction we need to replace <link-to-AMPS-distribution-archive> with the actual download link of the AMPS Server of the version that will be used.

2. Build the container:

docker build .

Once built, the the container id for the AMPS container will be listed, for example:

Successfully built 377c409b35e4

3. Use the container id to Start the AMPS container:

docker run -p 8085:8085 -p 9007:9007 -p 9008:9008 <container_id>

Notice that the command uses the -p flag to publish the ports that AMPS uses from the container to the host. We've attached an archive with the Dockerfile and a sample AMPS configuration file. You can replace/modify the configuration file and the docker file to fit your needs.

We recommend that any Linux system that hosts AMPS be tuned as described in the Linux Operating System Configuration section of the AMPS User Guide.

Troubleshooting Common Issues

  • Filesystem errors when storing data on an external directory

    Filesystems mounted from the host operating system may have limited functionality, particularly when the host operating system isn't Linux. 60East recommends that you avoid storing AMPS data in a directory mounted from the host operating system.

  • libnuma: Warning: /sys not mounted or invalid.

    This warning indicates that AMPS is not able to gather information about the hardware that hosts the instance, and will therefore use default assumptions about the hardware. This warning is expected when running on Docker. (Notice that, as a result of this limitation in Docker, it is not expected that AMPS will fully take advantage of the available hardware when running in a Docker container).

  • Capacity errors

    An AMPS docker container requires the same capacity settings as physical hardware or a virtual machine, as noted above. If the container does not have sufficient overall capacity, or the Linux Operating System settings are not configured as required for AMPS, the AMPS instance may fail to start or exit with an error indicating that resources are not available.

  • Reduced performance

    As mentioned above, testing in the 60East labs indicates that the default Docker configurations can have significantly lower performance as compared to a virtual machine (in a hosting environment such as VMWare Workstation or VirtualBox) or a native operating system install on identical hardware. The difference seems to be greater when the container is hosted on an operating system other than Linux. For this reason, 60East recommends carefully testing performance with Docker. If a container is hosted in a different environment in development than in deployment, best practice is to measure performance on the deployment environment, not the development environment. Any metrics from the development environment may be misleading due to differences in Docker performance.

1KB
docker_instance.zip
archive

Last updated