[LINUX] Start Nginx with docker without putting Nginx in CentOS8

When posting to Qiia, contents posted on my blog for Qiia I decided to fix it and post it. The amount of work to correct, such as inserting images, headings, and citations, was relatively large.

Start Nginx without Nginx in CentOS8

It is possible to start Nginx without installing Nginx in CentOS8. Specifically, install docker and start Nginx using docker. # nginx -V 2020-10-18_185817.png

The command was not found because Nginx is not installed on CentOS8. After that, it prompts me to install nginx, but no. Install docker in this state and start Nginx using docker.

Reference source for installing docker on CentOS 8

<a href="https://docs.docker.com/engine/install/centos/" target in docs.docker.com I thought I'd refer to = "_ blank"> Install Docker engine on CentOS , but it was intended for CentOS7, not for CentOS8. Therefore, Install docker on CentOs8 and install it. I decided to do it.

Install docker on CentOS8 (failure)

As a procedure ① Uninstall the old version by referring to Install Docker engine on CentOS Implemented # dnf remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

(2) Check the version of CentOS Linux # cat /etc/centos-release CentOS Linux release 8.2.2004 (Core)

③ Confirmation of addition of repository # dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

④ Check the repository # dnf repolist

⑤ Install Docker Engine (failure) # dnf install --nobest docker-ce

2020-10-18_182424.png Immediately after installing CentOS8, there was no target for uninstalling the old version of docker, so there is no problem if you skip "(1) Uninstall the old version by referring to Installing the Docker engine on CentOS".

Install docker on CentOS8 (successful)

Since there is a conflicting package and the installation of Docker Engine failed, I added a command line to replace the conflicting package as warned and installed docker on CentOS 8 again. ⑤ Install Docker Engine (successful) # dnf install --nobest docker-ce --allowerasing

2020-10-18_182500.png Since docker installation was successful ⑥ Check the version of docker # docker --version Docker version 19.03.13, build 4484c46d9d

⑦ Automatic start of docker and start setting # systemctl enable docker # systemctl start docker

Implemented. 2020-10-18_182614.png

Start Nginx using docker

⑧ Start Nginx using docker # docker run --name testnginx -d -p 8080:80 nginx

⑨ Information display of docker container status # docker ps -a

2020-10-18_232838.png I'm running nginx with docker run with the name "testnginx" and : at 8080: 80. When you display the container status with docker ps -a It can be confirmed that NAMES is "testnginx" and PORTS is "0.0.0.0:8080-> 80 / tcp", which are executed under the specified conditions. Please also note that the CONTAINER ID is running on "c917cab 45486" as we will check it later.

Access localhost: 8080 in Firefox

Access localhost: 8080 in Firefox. 8080 is because I specified "-p 8080:80" in docker run. 2020-10-18_182852.png I succeeded in starting Nginx using docker without installing Nginx in CentOS8.

Docker container, delete image

⑩ Stop docker container and image # docker stop c917cab45486

⑪ Delete docker container and image # docker rm c917cab45486

⑫ Display information of docker container status # docker ps -a

2020-10-18_234125.png An error will occur if you try to delete a running container or image, so docker stop is used to specify CONTAINER ID "c917cab45486" in advance. After that, I deleted it with docker rm and confirmed that the docker container and image disappeared with docker ps -a.

Recommended Posts

Start Nginx with docker without putting Nginx in CentOS8
Start Caddy with docker without putting Caddy in CentOS8
Until you start Jupyter with Docker
How to log in to Docker + NGINX
Create Python + uWSGI + Nginx environment with Docker
Build a CentOS Linux 8 environment with Docker and start Apache HTTP Server
Build NGINX + NGINX Unit + MySQL environment with Docker
How to install python3 with docker centos
Hello World with gRPC / go in Docker environment
Build Django + NGINX + PostgreSQL development environment with Docker
mod_wsgi talks about putting it in with pip
Start Django in a virtual environment with Pipenv
Start a simple Python web server with Docker
Create Nginx + uWSGI + Python (Django) environment with docker
Run Flask on CentOS with python3.4, Gunicorn + Nginx.
Play with CentOS 8
Change the time zone with Docker in Oracle Database
Japanese can be used with Python in Docker environment
Output log to console with Flask + Nginx on Docker
Start numerical calculation in Python (with Homebrew and pip)
Setting to run application in subdirectory with nginx + uwsgi