From the course: Web Servers and APIs using C++
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Serving the example - C++ Tutorial
From the course: Web Servers and APIs using C++
Serving the example
- [Instructor] Let's run our web server directly in the container. From the build directory, type ./hello_crow. The output looks promising. Our server tells us it is using PORT 18080. Let's try accessing it from the browser. We enter localhost:18080 and press Enter. Uh-oh. We can't access our site. Why? Each docker container is by default isolated. None of its ports are open. In order to access our server, we need to open a port and tell the server which port to use. We open a port by adding the -p option to the docker run command. The -p option opens a port and allows us to map it to the host machine. The first number is the host machine's port number. The second number is the container's port number. The port numbers don't have to match. The -e option allows us to create an environmental variable. We'll use it to tell the server which port it is using. So we go back to the terminal. Control + C to stop that from running. We can exit. Then from here, we're gonna enter docker run -v…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
(Locked)
Installing Docker1m 29s
-
(Locked)
Installing Atom35s
-
(Locked)
Creating a Dockerfile5m 16s
-
(Locked)
Running a Dockerfile1m 50s
-
(Locked)
Adding a volume2m 33s
-
(Locked)
Building Crow9m 33s
-
(Locked)
Serving the example3m 7s
-
(Locked)
Challenge: Modify the example page31s
-
(Locked)
Solution: Modify the example page2m
-
(Locked)
-
-
-
-
-
-