Use Docker to build and run dapps
What is Docker?
Welcome to the world of Docker, an essential tool for software development. Docker packages software into units known as containers, ensuring consistency, isolation, portability, and scalability.
Docker is particularly useful in dapp development. It helps manage microservices, maintain consistent environments throughout development stages, and simulate a decentralized network during testing.
Understanding Docker begins with understanding Docker images and containers. A Docker image, created from a Dockerfile, is a package that contains everything needed to run the software. A Docker container is a running instance of this image.
Building and Running a Docker Image
You can create a Docker image using the docker build command with a Dockerfile. Once the image is created, you can run a Docker container using the docker run command.
In the context of the example Soroban dapps, understanding how to build Docker images is crucial. The Docker images serve as the basis for our container, which provides the environment for our dapp to run.
Here's an example from our example
To illustrate the process, let's take an example from our example crowdfund dapp. In order to build the Docker image, you utilize a command that is encapsulated within our Makefile:
make build-docker
This command simplifies the Docker build process and ensures it's consistently executed each time. When you run make build-docker
, Docker executes the following instructions:
docker build . \
--tag soroban-preview:11 \
--force-rm \
--rm