Docker Notes

Notes on AWS EC2


Commands Notes

The docker build -t myapp-frontend . command is used to create a Docker image from the Dockerfile in the current directory, which is denoted by the . at the end of the command. Here's the breakdown:

docker build: This is the Docker command to build a new image. -t myapp-frontend: The -t flag tags the new image with the name myapp-frontend. This name is what you use to refer to the image when you want to run a container from it. .: This specifies the build context to the current directory. Docker will look here for the Dockerfile and all files that are copied into the image.

The docker run -d -p 3000:3000 --name my-frontend-container myapp-frontend command is used to run a Docker container based on the myapp-frontend image. Here's the breakdown:

docker run: This command is used to run a Docker container. -d: This flag tells Docker to run the container in detached mode, which means the container runs in the background and does not block the terminal. -p 3000:3000: This option maps the container's port 3000 to port 3000 on the host machine, so that you can access the application using http://localhost:3000 on your browser. In the option -p 3000:3000, the first 3000 refers to the port on the host machine, and the second 3000 refers to the port inside the container. So when you visit http://localhost:3000 on your host machine, Docker routes that request to port 3000 on the container running your application. --name my-frontend-container: This assigns the name my-frontend-container to the running container, so you can easily refer to it with other Docker commands. myapp-frontend: This specifies the image to use to create the container, which is the image you previously built with the docker build command.