Docker实战(一):Docker安装与基础命令

来源:互联网 发布:js在html中的位置 编辑:程序博客网 时间:2024/05/22 12:23

Docker安装

我是在Ubuntu 16上安装的docker,linux安装docker只需要一个命令:

sudo apt-get install docker.io

运行完后,可以在终端输入docker看到以下信息证明我们安装成功了
注:提示权限问题就添加sudo

docker
Usage: docker [OPTIONS] COMMAND [arg…]
docker daemon [ –help | … ]
docker [ –help | -v | –version ]

A self-sufficient runtime for containers.

Options:

–config=~/.docker Location of client config files
-D, –debug Enable debug mode
-H, –host=[] Daemon socket(s) to connect to
-h, –help Print usage
-l, –log-level=info Set the logging level
–tls Use TLS; implied by –tlsverify
–tlscacert=~/.docker/ca.pem Trust certs signed only by this CA
–tlscert=~/.docker/cert.pem Path to TLS certificate file
–tlskey=~/.docker/key.pem Path to TLS key file
–tlsverify Use TLS and verify the remote
-v, –version Print version information and quit

Commands:
attach Attach to a running container
build Build an image from a Dockerfile
commit Create a new image from a container’s changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes on a container’s filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container’s filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on a container or image
kill Kill a running container
load Load an image from a tar archive or STDIN
login Register or log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
network Manage Docker networks
pause Pause all processes within a container
port List port mappings or a specific mapping for the CONTAINER
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart a container
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save an image(s) to a tar archive
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop a running container
tag Tag an image into a repository
top Display the running processes of a container
unpause Unpause all processes within a container
update Update resources of one or more containers
version Show the Docker version information
volume Manage Docker volumes
wait Block until a container stops, then print its exit code

Run ‘docker COMMAND –help’ for more information on a command.

安装完以后,也可运行以下命令查看版本信息:

docker -v
docker version
docker info

当利用 docker run 来创建容器时,Docker 在后台运行的标准操作包括:

  • 检查本地是否存在指定的镜像,不存在就从公有仓库下载
  • 利用镜像创建并启动一个容器
  • 分配一个文件系统,并在只读的镜像层外面挂载一层可读写层
  • 从宿主主机配置的网桥接口中桥接一个虚拟接口到容器中去
  • 从地址池配置一个 ip 地址给容器
  • 执行用户指定的应用程序
  • 执行完毕后容器被终止
1 0
原创粉丝点击