因为要用Docker 部署一些软件并作一些配置,开始学习和使用一下大名鼎鼎的docker.
一开始我以为Docker是默认包含在linux的安装文件里的,然而并不是。所以为了省事一定要有网络。
我们开始Docker的使用配置之旅。
先在虚拟机装一个Linux吧。 Ubuntu是我最喜欢的。直接装成了GUI的了~~~
补充一些Docker 相关的。
Docker 提供一个container 让软件跑在这个container里面,类似VM跑在hypervisor上.不必关心HW是什么,是什么系统,只要可以运行Dockers就可以了。这样可以快速开发部署~~~
上Docker。Ubuntu 18.04 LTS.
装玩系统连上网然后开始安装Docker.
$sudo apt update
安装需要的包
$sudo apt install apt-transport-https ca-certificates curl software-properties-common
添加GPG key 以便Docker repository到你的系统
$curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
添加 Docker repository到你的系统
$sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable”
$sudo apt update
安装Docker
$sudo apt install docker-ce
说明一下 Docker有两个版本一个是CE 给独立开发者和小团队用的
一个是企业的EE的版本,我们学习一下 用的都是CE的。
启动Docker.
$sudo systemctl status docker
我是用root来跑的,和实际的生产环境不一样,大家自己切换。
Docker 命令是下面这样的
docker [option] [command] [arguments]
attach Attach local standard input, output, and error streams 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 to files or directories 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 Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
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 one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
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 one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes
跑一个
$docker run -it ubuntu
docker会在本地找要运行的image 如果没有就去网上下一个,ubuntu 我没有它自己就帮我下了一个并运行。