Docker installs nextcloud+mysql to create a private cloud disk

Table of contents

 

1. Pull the image       

2. Start the database

3. Create a database

4. Start nextcloud

5. Modify the nextcloud configuration

6. Connect the browser to nextcloud


1. Pull the image       

docker pull mysql:5
docker pull nextcloud:21

        Note: Version 5 is selected for mirroring MySQL, and version 21 is selected for Nextcloud to prevent errors caused by version issues. 

2. Start the database

docker run --name=nextcloud_db -e MYSQL_ROOT_PASSWORD=passwd -d mysql:5

        Note: name is followed by the name of the mysql container, you can add -v local address: /var/lib/mysql specifies the storage address

3. Create a database

        implement

docker exec -it nextcloud_db mysql -u root -p

        Then enter the password to enter mysql, and then create a new user

CREATE USER 'username' IDENTIFIED BY 'password‘;
GRANT ALL ON *.* TO 'username'@'%';
flush privileges;
exit;

        After exit, use the newly created user to log in to the database and create a database

mysql -u username -p
CREATE DATABASE nextcloud;
exit;

4. Start nextcloud

docker run -d --name=nextcloud --link nextcloud_db:db -v ~/docker-test/nextcloud:/var/www/html/ -p 8080:80 --restart=always nextcloud:21

        Note: link means to link nextcloud to the mysql database, and the db after: means the name mapped to nextcloud, which will be used later when the browser connects.

5. Modify the nextcloud configuration

        First change the source of the container nextcloud, and then install vim

Use docker inspect nextcloud         outside the container to get the value of IPAddress, then enter the container and add to /etc/apach2/sites-enabled/000-default.conf: 

        Value of ServerName IPAddress

        As shown below:

        Exit the container, restart the container

docker restart nextcloud

6. Connect the browser to nextcloud

        IP: external network port to enter the page 

        Then create a user and configure the database, as shown below:

          After selecting mysql as data in the nextCould installation option, you can no longer use the computer host 127.0.0.1: 3306 as the mysql address

        To select network − name: port network-name: portnetword−name:port to connect to mysql, such as the db previously mapped to the container

Guess you like

Origin blog.csdn.net/sky_amazing666/article/details/119769433