Centos uses docker to deploy nacos

insert image description here

Centos uses docker to deploy nacos

For deploying Nacos with Docker, you can follow the steps below:

  1. Install Docker and Docker Compose on your server.
  2. Create a directory for storing Nacos data, eg /path/to/nacos/data.
  3. Create a docker-compose.ymlfile and copy the following content into it:
version: '3'
services:
  nacos:
    image: nacos/nacos-server:latest
    container_name: nacos
    ports:
      - 8848:8848
    volumes:
      - /path/to/nacos/data:/home/nacos/init.d/custom
    restart: always

Make sure to replace the above /path/to/nacos/datawith the actual path used to store the data.

  1. Save and close docker-compose.ymlthe file.
  2. Open a terminal and docker-compose.ymlstart the Nacos container by running the following command in the directory containing the file:
docker-compose up -d
  1. Docker will download the Nacos image and create the container. Once the container is started successfully, you can http://服务器IP地址:8848/nacosaccess the Nacos console via .
    Note: need to 服务器IP地址replace the actual IP address of your server.

Now, you have successfully deployed Nacos using Docker. You can manage information such as configurations and services through the console, and start using Nacos as a configuration center and service registry in your project.

If you want to stop a Nacos container, you can docker-compose.ymlrun the following command in the directory containing the file:

docker-compose down

This will stop and remove the Nacos container.

Note that the above steps provide a basic way to deploy Nacos using Docker. You can also do more configuration and customization according to your needs, such as adjusting port mapping, adding environment variables, etc. For detailed configuration information and options, please refer to Nacos official documents or related resources.

Centos firewall releases nacos access port

On CentOS systems, you can use Firewalld as a firewall management tool to configure rules to allow Nacos to access ports. The following is an example of configuring the CentOS firewall (Firewalld):

  1. First, check that Firewalld is installed and running. Check the firewalld status by running the following command:

    sudo systemctl status firewalld
    

    If the result shows "active (running)", it means Firewalld is already running.

  2. Next, add a port rule to allow through. Assuming you want to allow Nacos default port (8848) to access, please execute the following command:

    sudo firewall-cmd --zone=public --add-port=8848/tcp --permanent
    

    This will add a permanent rule allowing TCP traffic on port 8848.

  3. Finally, reload the Firewalld configuration for the changes to take effect:

    sudo firewall-cmd --reload
    

With this, you have configured a rule in CentOS's firewalld to allow access through port 8848. Please note that if you modified the port of Nacos, please update the port number in the above command accordingly.

Once configured, you should be able to access the setup port used by Nacos through the firewall.

Make sure you configure firewall rules with security in mind and limit access to only necessary trusted sources.

Guess you like

Origin blog.csdn.net/weixin_53742691/article/details/131731792