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.
It is possible to start Nginx without installing Nginx in CentOS8. Specifically, install docker and start Nginx using docker.
# nginx -V
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.
<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.
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
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".
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
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.
⑧ Start Nginx using docker
# docker run --name testnginx -d -p 8080:80 nginx
⑨ Information display of docker container status
# docker ps -a
I'm running nginx with docker run with the name "testnginx" and
Access localhost: 8080 in Firefox. 8080 is because I specified "-p 8080:80" in docker run. I succeeded in starting Nginx using docker without installing Nginx in CentOS8.
⑩ 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
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