
- Docker - Home
- Docker - Overview
- Docker - Installing on Linux
- Docker - Installation
- Docker - Hub
- Docker - Images
- Docker - Containers
- Docker - Registries
- Docker - Compose
- Docker - Working With Containers
- Docker - Architecture
- Docker - Layers
- Docker - Container & Hosts
- Docker - Configuration
- Docker - Containers & Shells
- Docker - Dockerfile
- Docker - Building Files
- Docker - Public Repositories
- Docker - Managing Ports
- Docker - Web Server
- Docker - Commands
- Docker - Container Linking
- Docker - Data Storage
- Docker - Volumes
- Docker - Networking
- Docker - Security
- Docker - Toolbox
- Docker - Cloud
- Docker - Build Cloud
- Docker - Logging
- Docker - Continuous Integration
- Docker - Kubernetes Architecture
- Docker - Working of Kubernetes
- Docker - Generative AI
- Docker - Hosting
- Docker - Best Practices
- Docker - Setting Node.js
- Docker - Setting MongoDB
- Docker - Setting NGINX
- Docker - Setting ASP.Net
- Docker - Setting MySQL
- Docker - Setting Go
- Docker - Setting Rust
- Docker - Setting Apache
- Docker - Setting MariaDB
- Docker - Setting Jupyter
- Docker - Setting Portainer
- Docker - Setting Rstudio
- Docker - Setting Plex
- Docker Setting - Flame
- Docker Setting - PostgreSql
- Docker Setting - Mosquitto
- Docker Setting - Grafana
- Docker Setting - Nextcloud
- Docker Setting - Pawns
- Docker Setting - Ubuntu
- Docker Setting - RabbitMQ
- Docker - Setting Python
- Docker - Setting Java
- Docker - Setting Redis
- Docker - Setting Alpine
- Docker - Setting BusyBox
- Docker Setting - Traefik
- Docker Setting - WordPress
- Docker Useful Resources
- Docker - Quick Guide
- Docker - Useful Resources
- Docker - Discussion
Docker - Setting Pawns
Pawns.app or Pawns is a platform allowing users to earn money by sharing their bandwidth or completing surveys. Companies use the bandwidth that users share through their IP addresses to run their services, and users can earn more money by participating in surveys that cover a variety of topics.
In this chapter, we will dive deep into how we can dockerize Pawns. Containerizing the Pawns app will allow us to run it in an isolated environment to achieve consistency across different environments without manually changing system configurations.
Prerequisites for Dockerizing Pawns
Before starting this guide, make sure you have the following prerequisites −
- Docker Application − Verify that Docker is installed locally on your computer. It is available for download on Docker's official website. It would also help if you knew a little bit about Docker.
- Docker Compose − To set up Pawns with Docker via Docker Compose, make sure you have Docker Compose configured on your computer.
- Interface Command Line (CLI) − You would be better able to comprehend this article if you had a basic understanding of the command line interface (CLI) and its commands.
- Text Editor − Writing configuration files would require the use of a text editor such as VSCode or Sublime Text.
Setting up a Pawns Project
To start your container, you need to have a Docker image since it contains all the instructions and data, such as environment variables, database, and services that make up your application.
You have two options − either pull the pre-built Docker image or create a custom Pawns project that will serve as the Docker image for your container.
You have greater control over the environment when you create a custom image. We will talk about creating a custom Pawns project in this section.
Step 1: Create a Project Directory
Create a project directory where all the files related to the Pawns.app will be stored.
# Create a folder for the Pawns project $ mkdir pawns-docker # Navigate into the directory $ cd pawns-docker

Step 2: Create a Basic Dockerfile
Navigate to the pawns-docker directory and create a dockerfile in it which will later be populated.
# Create a Dockerfile $ touch Dockerfile
Open the dockerfile in any text editor and add the following instructions to it. Each of these instructions will create a separate Docker image layer.
# Use an appropriate base image FROM iproyal/pawns-cli:latest # Set a working directory WORKDIR /usr/src/app # Copy the application code (if needed) COPY . . # Install any dependencies (if required) # RUN npm install # Uncomment if Node.js is involved # Expose the default port EXPOSE 8080 # Define environment variables (optional, modify as needed) ENV NODE_ENV=production # Specify the default command to run CMD ["npm", "start"]
The base image is set to the pawns/app and the exposed port is 8080.

Step 3: Build a Custom Docker Image
Once the docker file is created, create a Docker image which will store the instructions to run the container.
$ docker build -t pawns-app .

Step 4: Run the Pawns Container
Lets run a Pawns container using the image that we just created.
$ docker run -d --name pawns -p 8080:8080 pawns-app

Step 5: Persisting Data with Volumes
Data in the Pawns container is stored temporarily i.e., it will only last as long as you have the container. You can use Docker volumes to store the data permanently so that it does not get lost even after you delete your Pawns container.
Even if you decide to delete the container, you can save the data forever thanks to Docker volumes.
$ docker run -d --name pawns -p 8080:8080 -v ./pawns-data:/app/data pawns-app

Using a pre-built Docker Image
To install Pawns in Docker, you can use the official Docker image that has already been built, saving you the trouble of creating your own.
Step 1: Pull the Pawns Image
Pull the Docker image for Pawns before running the container.
$ docker pull iproyal/pawns-cli:latest

Step 2: Run the Pawns Container
Once you pull the Docker image, its time to run the Pawns container.
$ docker run -d --name pawns -p 8080:8080 iproyal/pawns-cli:latest
Where,
- -d − represents the detached mode which means this process will run in the background
- --name pawns − represents the name of your container
- -p 8080:8080 − maps port 8080 on your local machine to port 8080 in the Pawns container. This allows you to access Pawnss dashboard by visiting http://localhost:8080 on your browser.
- pawns/app − name of the docker image that is used to create the container

Using Docker Compose to Set Up Pawns
Lets use the official Docker image to create Docker containers using Docker compose.
Step 1: Create a docker-compose.yml file
Create a docker-compose.yml file in your pawns directory.
$ touch docker-compose.yml
Your directory structure should look like this now −
pawns-docker/ docker-compose.yml Dockerfile pawns-data/

Step 2: Populate .yml file
Open your docker-compose.yml file in a text editor and add the following configuration to it −
version: '3.8' services: pawns: image: iproyal/pawns-cli:latest container_name: pawns restart: unless-stopped ports: - "8080:8080" volumes: - ./pawns-data:/app/data environment: - APP_ENV=production - APP_PORT=8080 - DATABASE_URL=sqlite:///app/data/pawns.db - LOG_LEVEL=info networks: - pawns-network logging: driver: "json-file" options: max-size: "10m" max-file: "3" healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/ || exit 1"] interval: 30s retries: 3 start_period: 30s timeout: 10s networks: pawns-network: driver: bridge volumes: pawns-data: driver: local
Step 3: Run Docker Compose
$ docker-compose up -d

Conclusion
In this chapter, we have successfully dockerized Pawns. We created a Docker container and ran the Pawns instance making the service consistent across different environments and isolated from other applications. Docker volumes ensure that your persisted data is safe even if your container crashes or is removed.
Pawns is easier to maintain and deploy when run in Docker, and you can automate and expedite the setup process by using Docker Compose.
FAQs on Dockerizing Pawns
In this section, we have collected a set of FAQs on dockerizing Pawns followed by their brief answers.
1. If my Pawns container gets deleted, will my data get deleted too?
Data stored inside the Pawns container will be considered temporary and hence will be lost once you delete the container. However, data stored in Docker volumes will be permanent and accessible even after the deletion of the container.
In the docker-compose.yml configuration, a section called ./pawns-data:/app/data is created on the host machine which is used to hold the configuration files and logs. This ensures the safety of the data and allows it to be recovered by creating a new container with the same volume.
2. Can I use Pawns with an external database like MySQL or PostgreSQL?
PostgreSQL, MySQL, and MongoDB are examples of third-party databases that Pawns does not support. The platform's configuration, logs, and other data are kept in local files as part of its lightweight design.
Usually, the mounted volume (./pawns-data:/app/data) is where these files are kept. This data can be preserved by using Docker volumes, however, Pawns is not meant to interact with external databases for data management or storage. You might need to integrate an extra service to handle more advanced data handling if your application calls for it.
3. Can I secure my Pawns instance against unwanted access?
You can follow proper network security protocols to guard Pawns. To restrict access to Pawns' exposed ports, use firewall rules. For instance, you can set up your firewall so that port 8080 can only be accessed by particular IP addresses or subnets.
To protect your Pawns instance behind SSL/TLS encryption, use a reverse proxy such as Nginx or Traefik. This guarantees the encryption of any data exchanged between your users and the Pawns service. By using a VPN to hide Pawns, you can further restrict access. An additional would be that the Pawns instance could only be accessed by those with VPN access.