Load 20min virtual container w/ web-app for any user to test.

Updated: Mar 02, 2025

Load 20min virtual container w/ web-app for any user to test.

To load a 20-minute virtual container with a web-app for any user to test, you can follow the steps below using Docker and Docker Hub:

  1. Create a Dockerfile: First, you need to create a Dockerfile for your web-app. A Dockerfile is a text document that contains all the instructions Docker needs to build an image for your application. Here's an example Dockerfile for a simple Node.js app:
# Use an official Node runtime as a parent image
FROM node:14

# Set the working directory in the container to /app
WORKDIR /app

# Add the current directory contents into the container at /app
ADD . /app

# Install any needed packages specified in package.json
RUN npm install

# Make port 8080 available to the world outside this container
EXPOSE 8080

# Define the command to run when the container launches
CMD ["npm", "start"]
  1. Build the Docker image: Next, you need to build the Docker image using the Dockerfile. Run the following command in your terminal:
docker build -t my-webapp .

Replace "my-webapp" with the name you want to give to your Docker image.

  1. Push the Docker image to Docker Hub: To make the image available to anyone, you need to push it to a public Docker registry like Docker Hub. First, you need to create an account on Docker Hub and log in. Then, run the following command to push the image:
docker push my-webapp

Replace "my-webapp" with the name of your image.

  1. Create a Docker Hub container: Now, you can create a container from the image on Docker Hub that will run for 20 minutes. You can use the following command to create a container with a 20-minute timeout:
docker run --rm -it --name my-container my-webapp bash -c "sleep 1200 && exit"

Replace "my-container" with the name you want to give to your container, and "1200" with the number of seconds you want the container to run for (20 minutes = 1200 seconds).

  1. Share the container URL: Finally, you can share the URL of the container with the user so they can test the web-app. To get the URL of the container, run the following command:
docker ps -aqf name=my-container

Replace "my-container" with the name of your container. This command will return the container ID. Then, use the following command to get the public IP address of the Docker host and the port number where the container is running:

docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}:{{.Ports.8080.HostPort}}{{end}}' my-container

Replace "my-container" with the name of your container. This command will return the public IP address and port number of the container. Share this URL with the user, and they can test the web-app by visiting it in their web browser.

Note: Depending on your network configuration, you might need to use a different method to access the container from outside your network. In that case, you might need to use a reverse proxy or a load balancer to forward traffic to the container.