Open a Terminal window (Mac, Linux) or CMD window (Windows) and place yourself in the directory where the source code of your project is. Then, type the following command:
docker build . -t my_api:v1
where:
- "." represents the current directory where you are
- "-t" means you want to tag your container image with name
- "my_api" is the main name of your container image
- "v1" is the part of the tag name related to the container version
Open a Terminal window (Mac, Linux) or CMD window (Windows) and type:
docker run -p 5000:5000 my_api:v1 -it api_container
where:
- "my_api:v1" is the local image you want to run as a container
- "api_container" is the name you want to assign to this container image when it is run.
Open a Terminal window (Mac, Linux) or CMD window (Windows) and type:
docker exec -it <container_id> ash
NOTE: ash
is the built-in shell in Alpine linux.