Solution to Challenge
Learn the solution to the challenge you completed.
We'll cover the following
Solution
-
To build and tag an image in a single command with
challenge
andtry
as image and tag name respectively:docker image build -t <your_username>/challenge:try .
or for
Dockerfile.prod
:docker image build -f Dockerfile.prod -t <your_username>/challenge:try .
-
List down all images:
docker image ls
-
Push your image to the repository:
docker push <your_username>/challenge
or with tag:
docker push <your_username>/challenge:try
-
Verify on your repository that the image has been built.
-
A container is run according to the required instructions, using the image you built above:
docker run -it --rm --name nodecontainer -p 8080:3000 \ <your_username>/challenge:try
-it
runs an interactive session.--rm
removes the container after the container stops.--name
is used to name the container as nodecontainer.-p
is used to define both the exposed port (8080
) and the default port (3000
) on which node is running.- Image name is
<your_username>/challenge:try
that was built above.
-
Click on the URL in front of βYour app can be found here:β to verify if your app is up successfully.
π Click on the βRunβ button to view the solution running.
π The tag has been changed to
solved
, so your correct image does not get overwritten.
Get hands-on with 1400+ tech skills courses.