[DOCKER] How to correctly check the local HTML file in the browser

This article assumes an environment where Docker works.


Quickly check the local HTML file with a browser.

Common cases

When you are given a rough HTML file like "This HTML doesn't work for some reason, can you check it?", If you open the browser as it is, you may have trouble reading the external file, right?

A long time ago, I used to launch XAMP and MAMP, and use OS standard sharing services. The publishing procedure is a bit cumbersome, and I often forget to stop publishing and continue to use extra resources.

With the birth of Docker, there is an easy way to check local HTML files without polluting the OS as much as possible.


Start the server locally and temporarily publish the directory containing the HTML files.

Go to the HTML file directory in the console

docker run -v $(pwd):/usr/share/nginx/html:ro --rm -p 8080:80 nginx

If this is the only file name test.html You will be able to access the file with.

You can see the communication log because it is not started as a daemon without the -d option, and when you stop the Ctrl + C process, the container disappears with --rm, so it is clean. Since you don't have to name the container with --name, the command is short and easy to remember.

For those who only accept Apache for religious reasons

docker run -v $(pwd):/usr/local/apache2/htdocs/:ro --rm -p 8080:80 httpd

Please start up with.

If $ (pwd) doesn't work or you don't understand the meaning, please specify the directory path you want to publish as follows.

docker run -v /Users/qiita/Downloads:/usr/share/nginx/html:ro --rm -p 8080:80 nginx


I wrote a similar article in the past, but I realized that I should use the --rm option to clean up after finishing without having to make it a daemon separately, so I wrote it again.

Previous article https://qiita.com/rspepe/items/6f7f5eb31a04185bafbd

Recommended Posts

How to correctly check the local HTML file in the browser
How to check the logs in the Docker container
How to check Rails commands in the terminal
How to specify the resource path in HTML import
How to debug the generated jar file in Eclipse
How to get the length of an audio file in java
[Java] How to use the File class
How to delete the wrong migration file
How to delete the migration file NO FILE
How to add jar file in ScalaIDE
How to get the date in java
Android development, how to check null in the value of JSON object
How to add sound in the app (swift)
How to bind to property file in Spring Boot
How to build the simplest blockchain in Ruby
[Spring Boot] How to refer to the property file
How to check the latest version of io.spring.platform to describe in pom.xml of Spring (STS)
How to set environment variables in the properties file of Spring boot application
How to set the display time to Japan time in Rails
[Java] How to omit the private constructor in Lombok
How to send value in HTML without screen transition
[Java] How to extract the file name from the path
Organized how to interact with the JDK in stages
How to display a browser preview in VS Code
How to download a file (Servlet, HTML, Apache, Tomcat)
How to determine the look-ahead request (Prefetch) from the browser
How to test file upload screen in Spring + Selenium
How to convert a file to a byte array in Java
[Rails] How to display an image in the view
How to install Docker in the local environment of an existing Rails application [Rails 6 / MySQL 8]
How to use UsageStatsManager in Android Studio (How to check the startup time of other apps)
How to save a file with the specified extension under the directory specified in Java to the list
How to check the WEB application created in the PC development environment on your smartphone
How to check if the characters entered in the Swift Text Field are email addresses
How to get the class name / method name running in Java
How to use the getter / setter method (in object orientation)
How to read your own YAML file (*****. Yml) in Java
[AWS] How to check logs
How to set chrony when the time shifts in CentOS7
How to connect the strings in the List separated by commas
Memo: [Java] How to check groupId etc. described in pom.xml
How to create a placeholder part to use in the IN clause
How to specify an array in the return value / argument of the method in the CORBA IDL file
How to write comments in the schema definition file in GraphQL Java and reflect them in GraphQL and GraphQL Playground
How to retrieve the hash value in an array in Ruby
How to add the same Indexes in a nested array
How to derive the last day of the month in Java
How to check JSF version
How to change the contents of the jar file without decompressing
How to disable existing selected items in the select box
How to switch Java in the OpenJDK era on Mac
How to check the extension and size of uploaded files
[Rails5] japanMap link How to write parameters in js.erb file
[Rails] How to display information stored in the database in view
How to change the file name with Xcode (Refactor Rename)
How to check the database of apps deployed on Heroku
How to deal with the event that Committee :: InvalidRequest occurs in committee during Rspec file upload test
Method definition location Summary of how to check When defined in the project and Rails / Gem
How to create a jar file or war file using the jar command
[Rails / Routing] How to refer to the controller in the directory you created
It doesn't respond to the description in .js of the packs file