Creating a Custom Docker Image
- Until now we’ve used a pre-defined docker container in VS code let’s implement a custom docker image and run our program inside the container
- Create a docker file: Dockerfile is a simple text file that contains dependencies and pre-requisites
- Implement all dependencies on that docker file(I’m using different project which is not running inside a container)
- Create your devcontainer.json file inside the .devcontainer folder in your source directory and run command docker build command
- Press again F1 on your keyboard and reopen inside a container.
- Now congrats your program is running inside a custom 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.
Contact Us