Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation commands and methods of Docker and FastDFS

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "Docker and FastDFS installation commands and methods", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Docker and FastDFS installation commands and methods to use" article.

Characteristics of docker

1) get started quickly

Users can "docker" their programs in just a few minutes. Docker relies on the "copy-on-write" (copy-on-write) model, so that the application can be modified very quickly, so that the code can be changed at will.

You can then create a container to run the application. Most docker containers take less than a second to start. Due to the removal of the overhead of the management program, the docker container has high performance, and more containers can be run in the same host, so that users can make full use of the system resources as much as possible.

2) logical classification of responsibilities

With docker, developers only need to care about the applications running in the container, while operators only need to care about how to manage the container. Docker is designed to enhance the consistency between the development environment in which developers write code and the production environment in which applications are deployed. In order to reduce the kind of "everything is normal during development, it must be the problem of operation and maintenance (the test environment is normal, and if something goes wrong after launch, it must be the problem of operation and maintenance)."

3) Fast and efficient development life cycle

One of the goals of docker is to shorten the cycle of code from development, testing to deployment and running online, so that your application is portable, easy to build, and easy to collaborate. (to put it colloquially, docker is like a box, which can hold a lot of objects. If you need these items, you can take away the big box directly without having to take a piece from the box.)

4) encourage the use of service-oriented architecture

Docker also encourages service-oriented architectures and microservice architectures. Docker recommends that a single container run only one application or process, thus forming a distributed application model, in which applications or services can be represented as a series of interconnected containers, which makes it very easy to deploy applications, expand or debug applications, and improve the introspection of the program. (of course, you can run multiple application procedures in one container)

What do you do with docker?

The container provides isolation, and the container can provide a good sandboxie environment for various tests. And, the container book

It is inherently "standard" and is ideal for creating building blocks for services. Some application scenarios of docker are as follows:

Accelerate the local development and build process to make it more efficient and lightweight. Local developers can build, run, and share docker containers. Containers can be built in the development environment, then easily submitted to the test environment, and eventually into the production environment.

It allows independent services or applications to get the same results in different environments. This is useful in service-oriented architectures and deployments that rely heavily on micro-services.

Use docker to create an isolated environment for testing. For example, start a container for testing with a continuous integration tool such as jenkins ci.

Docker allows developers to build a complex program or architecture on the machine for testing instead of deploying and testing in a production environment in the first place.

Installation and operation

1. Install docker in ubuntu

Update the apt source index of ubuntu

Sudo apt-get update

The installation package allows apt to use the repository through https

Sudo apt-get install\ apt-transport-https\ ca-certificates\ curl\ software-properties-common

Add docker official gpg key

Curl-fssl https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add-

Set up the docker stable version repository

Sudo add-apt-repository\ "deb [arch=amd64] https://download.docker.com/linux/ubuntu\ $(lsb_release-cs)\ stable"

Update the apt source index after adding the warehouse

Sudo apt-get update

Install the latest version of docker ce (Community Edition)

Sudo apt-get install docker-ce

Check that docker ce is installed correctly

Sudo docker run hello-world

The following message appears, indicating that the installation was successful

In order to avoid entering sudo for each command, you can set user permissions and note that you must log out and log back in after execution

Sudo usermod-a-g docker $user

two。 Start and stop

After installing docker, the docker service has been started by default. To manually control the start and stop of the docker service, execute the following command

# start dockersudo service docker start#, stop dockersudo service docker stop# and restart dockersudo service docker restart

3. Docker mirror operation

1. List Mirror

Docker image ls

two。 Pull the image

To obtain an image, we can use the pull command to pull the image from the repository to the local, as shown in

Docker image pull library/hello-world

Since the official image files provided by docker are placed in the library group, it is the default group and can be omitted. Therefore, the above command can be written as follows.

Docker image pull hello-world

3. Delete Mirror

Docker image rm image name or image id

4. Docker container operation

Create a container

Docker run [option] Image name [commands passed into the startup container]

Commonly used optional parameters description:

-I means to run the container in "interactive mode"

-t indicates that the container will enter its command line when it starts. After adding these two parameters, the container creation can be logged in. That is, assign a pseudo terminal.

-- name names the created container

-v represents the directory mapping relationship (the former is the host directory, and the latter is the directory mapped to the host, that is, the host directory: the directory in the container). You can use multiple-v to map multiple directories or files. Note: it is best to do directory mapping, make changes on the host, and then share them on the container.

-d add the-d parameter after run, and a guardian container will be created to run in the background (in this way, the container will not be automatically logged in after it is created. If only-I-t is added, the container will be automatically entered after creation).

-p indicates the port mapping. The former is the host port, and the latter is the mapped port in the container. You can use multiple-p for multiple port mapping

-e set the environment variable for the container

-- network=host means to map the network environment of the host to the container, which has the same network as the host.

Interactive container

For example, create an interactive container and name it myubuntu

Docker run-it-- name=myubuntu ubuntu / bin/bash

The linux command can be executed at will in the container, which is a ubuntu environment, and when the exit command exits, the container stops.

Guarded container

Create a guardian container: for a container that needs to run for a long time, we can create a guardian container. The container does not stop when exit exits inside the container.

Docker run-dit-- name=myubuntu2 ubuntu

Enter the container that is already running

Docker exec-the first command executed after the container name or container id is entered

Such as

Docker exec-it myubuntu2 / bin/bash

View the container

# list the containers running on this machine docker container ls# list all containers on this machine, including the docker container ls that has been terminated-- all

Stop and start the container

# stop a running container docker container stop container name or container id# start a stopped container docker container start container name or container id# kill drop an already running container docker container kill container name or container id

Delete Container

Docker container rm container name or container id

5. Save the container as a mirror

We can save the container as a mirror with the following command

Docker commit container name image name

6. Mirror backup and migration

We can package the image into a file and copy it to others through the save command.

Docker save-o saved file name image name

Such as

Docker save-o. / ubuntu.tar ubuntu

After getting the image file, you can load the image locally using the load method.

Docker load-I. / ubuntu.tar

Install fastdfs using docker

1. Get the image

You can use an existing fastdfs docker image to run fastdfs.

To obtain an image, you can download it.

Docker image pull delron/fastdfs

After loading the image, you can turn on tracker and storage running fastdfs.

two。 Run tracker

Execute the following command to start the tracker service

Docker run-dti-- network=host-- name tracker-v / var/fdfs/tracker:/var/fdfs delron/fastdfs tracker

We map the fastdfs tracker run directory to the native / var/fdfs/tracker directory.

Execute the following command to see if tracker is running

Docker container ls

If you want to stop the tracker service, execute the following command

Docker container stop tracker

After stopping, rerun tracker by executing the following command

Docker container start tracker

3. Run storage

Execute the following command to start the storage service

Docker run-dti-- network=host-- name storage-e tracker_server=10.211.55.5:22122-v / var/fdfs/storage:/var/fdfs delron/fastdfs storage

Tracker_server= native ip address: 22122 native ip address do not use 127.0.0.1

We map the fastdfs storage running directory to the local / var/fdfs/storage directory

Execute the following command to see if storage is running

Docker container ls

If you want to stop the storage service, execute the following command

Docker container stop storage

After stopping, rerun storage by executing the following command

Docker container start storage

Note: if you cannot rerun, you can delete the fdfs_storaged.pid file in the / var/fdfs/storage/data directory, and then rerun storage.

The above is about the content of this article on "Docker and FastDFS installation commands and methods". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report