Local Development and Testing Using the Docker
- Open your project in VS code.
- Project is in Rust language as you can see here running this project inside a container.
- Press F1 and the below pop-up will occur.
- Click on Dev Containers and Add Dev Container Configuration Files.
- Click on Show all Definitions i.e. it will show you all the pre-defined Docker Containers for all types of programming languages.
- Now choose the appropriate pre-defined container, I’ll be choosing the Rust dev container
- Click on bullseye
- Select the additional extra features according to your project and click on ‘OK’
- After clicking ‘OK’ it will create a devcontainer.json file and click re-open in the container
Now your project is running inside a container.
How to Use Docker For Local Development and Testing?
Whenever you want to start a project you first check for the requirement i.e. we do the requirement analysis then we look for prerequisites dependencies. We install those dependencies and prerequisites and we simply built our project.
Suppose you are the person who built the project and you want to make your project open source. So there is another person who wants to contribute to your open source project first he/she will need to go through all dependencies and prerequisites for your project and that’s a lot of work.
That’s where docker comes into play, Docker is basically a text file that contains all the needed dependencies and prerequisites for a given project. You will simply share the docker file with your project so people can use that docker file to contribute to your project without even installing the dependencies and prerequisites.