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

Introduction to the installation steps and usage of Docker

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces "the installation steps and usage introduction of Docker". In the daily operation, I believe many people have doubts about the installation steps and usage introduction of Docker. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "installation steps and usage introduction of Docker". Next, please follow the editor to study!

1. Docker installation

(1) install docker

Install docker under Windows, download the installation package from https://www.docker.com/products/docker-desktop, execute it directly, and pay attention to the absence of Chinese in the installation directory.

After the installation is complete, start the sample docker from the command line and try it: docker run-d-p 80:80 docker/getting-started

Visit localhost:80 if a normal page appears:

It means that our docker environment has been installed successfully!

The ip and hostname of the machine where docker resides are configured in the hosts file, for example:

# Added by Docker Desktop

192.168.104.112 host.docker.internal

192.168.104.112 gateway.docker.internal

# To allow the same kube context to work on the host and the container:

127.0.0.1 kubernetes.docker.internal

The Docker administration interface can also see the list and status of docker:

The docker of cAdvisor installed in the next section is also shown here.

[docker basic commands]

Basic concepts:

Image id: mirror id

Container Id: container id. Artificial container ID is a concrete instance of image ID.

Command

Description

Docker image ls

View the current image

Docker run-d-p 80:80 docker/getting-started

Start docker, and the-p command exposes that port-d is daemon mode; docker/getting-started is the name of the docker repository.

Example 1:docker run-d-it-- name spark2 myspark:v1

Example 2: use mirror nginx:latest to start a container in interactive mode and execute the / bin/bash command inside the container

Docker run-it-- name nginx nginx:latest / bin/bash

Docker volume ls

Show volume list

Docker inspect containerId or imageId

View the details of a specific instance

Docker pull

Pull the image

Docker push

To upload an image, log in to the docker repository, for example:

Docker login

Docker tag local-image:tagname sandea/spark:tagname

Docker push sandea/spark:tagname

Docker cp

Transfer files between the Docker and the host.

Example 1:

Docker cp testtomcat:/usr/local/tomcat/webapps/test/js/test.js / opt

Copy test.js file from testtomcat container to host / opt

Example 2:

Docker cp / opt/test.js testtomcat:/usr/local/tomcat/webapps/test/js

In turn, copy all the host files to the container.

Docker start/stop containerId

Start / stop the docker container

Docker exec [options] container command [arg...]

Execute commands in a container

Docker rm container

Delete Container

Docker rmi image

Delete Mirror

Docker tag src_image [: tag] tar_image [: tag]

Create a copy of a mirror

Docker exec-it containerID / bin/bash

Enter the container interactive containerID: image ID

Docker save ubuntu:load > / root/ubuntu.tar

Docker load

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

Servers

Wechat

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

12
Report