侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

在Linux上安装docker和docker-compose

2023-11-14 星期二 / 0 评论 / 0 点赞 / 43 阅读 / 3519 字

安装docker在终端中执行以下命令安装:$ curl -sSL https://get.daocloud.io/docker | sh出现以下内容,说明安装成功了:Client: Version:

安装docker

在终端中执行以下命令安装:

$ curl -sSL https://get.daocloud.io/docker | sh

出现以下内容,说明安装成功了:

Client: Version:      17.04.0-ce API version:  1.28 Go version:   go1.7.5 Git commit:   4845c56 Built:        Mon Apr  3 18:07:42 2017 OS/Arch:      linux/amd64Server: Version:      17.04.0-ce API version:  1.28 (minimum version 1.12) Go version:   go1.7.5 Git commit:   4845c56 Built:        Mon Apr  3 18:07:42 2017 OS/Arch:      linux/amd64 Experimental: falseIf you would like to use Docker as a non-root user, you should now consideradding your user to the "docker" group with something like:  sudo usermod -aG docker zhangdaofengRemember that you will have to log out and back in for this to take effect!

确认docker是否成功安装了:

$ sudo docker run hello-world

反馈如下,则安装成功。

Unable to find image 'hello-world:latest' locallylatest: Pulling from library/hello-world78445dd45222: Pull complete Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7Status: Downloaded newer image for hello-world:latestHello from Docker!This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 3. The Docker daemon created a new container from that image which runs the    executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it    to your terminal.To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID: https://cloud.docker.com/For more examples and ideas, visit: https://docs.docker.com/engine/userguide/

安装docker-compose

.

Docker Compose是一个用来定义和运行复杂应用的Docker工具。使用Compose,你可以在一个文件中定义一个多容器应用,然后使用一条命令来启动你的应用,完成一切准备工作。

.

一个使用Docker容器的应用,通常由多个容器组成。使用Docker Compose,不再需要使用shell脚本来启动容器。在配置文件中,所有的容器通过services来定义,然后使用docker-compose脚本来启动、停止和重启应用,以及应用中的服务以及所有依赖服务的容器。

运行下面的命令来安装 Compose:

curl -L https://github.com/docker/compose/releases/download/1.12.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-composechmod +x /usr/local/bin/docker-compose
.

**注意:**如果你在安装的时候出现了 “Permission denied” 的错误信息,这说明你的 /usr/local/bin 目录是不可写的,你需要使用超级用户来安装。运行 sudo -i , 然后运行上边的两个命令,然后 exit 退出。

.

也可以使用pip安装:

$ sudo pip install -U docker-compose

到这里安装就结束了;Compose已经安装完成。你可以使用 docker-compose --version 来进行测试。

广告 广告

评论区