ubuntu Docker手记

实用:Ubuntu安装docker - 腾讯云开发者社区-腾讯云

使用docker安装hyperf(ubuntu)_太阳上的雨天的博客-CSDN博客_docker 安装hyperf

参考官方安装地址:Install Docker Engine on Ubuntu | Docker Documentation

使用docker安装hyperf(ubuntu)
下载并运行 hyperf/hyperf 镜像,并将镜像内的项目目录绑定到宿主机的 /tmp/skeleton 目录

docker run -v /tmp/skeleton:/hyperf-skeleton -p 9501:9501 -it --entrypoint /bin/sh hyperf/hyperf:7.2-alpine-cli

镜像容器运行后,在容器内安装 Composer

wget https://github.com/composer/composer/releases/download/1.8.6/composer.phar
chmod u+x composer.phar
mv composer.phar /usr/local/bin/composer

将 Composer 镜像设置为阿里云镜像,加速国内下载速度

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer

通过 Composer 安装 hyperf/hyperf-skeleton 项目

composer create-project hyperf/hyperf-skeleton

进入安装好的 Hyperf 项目目录

cd hyperf-skeleton

启动 Hyperf

php bin/hyperf.php start

报错:提示需要安装redis
进入容器:

docker exec -it <容器id||容器名> bash

下载:

wget http://download.redis.io/releases/redis-4.0.2.tar.gz

解压安装包并安装:

tar xzf redis-4.0.2.tar.gz
cd redis-4.0.2
make
make install

要安装 Docker Engine,您需要以下 Ubuntu 版本之一的 64 位版本:

  • Ubuntu 小鬼 21.10
  • Ubuntu 多毛 21.04
  • Ubuntu 焦点 20.04 (LTS)
  • Ubuntu 仿生 18.04 (LTS)

卸载老版本

$ sudo apt-get remove docker docker-engine docker.io containerd runc

复制

设置新的储存器

更新apt包索引并安装包以允许apt通过 HTTPS 使用存储库

$ sudo apt-get update

$ sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

复制

添加官方的GPG密钥

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

复制

使用以下命令设置稳定存储库

$ echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

复制

安装 Docker 引擎

$ sudo apt-get update

复制

问题: E: The repository 'Index of linux/ubuntu/ \ Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details

忽略

$ sudo apt-get install docker-ce docker-ce-cli containerd.io

复制

报错: Reading package lists... Done Building dependency tree     Reading state information... Done Package docker-ce is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source

E: Package 'docker-ce' has no installation candidate E: Unable to locate package docker-ce-cli E: Unable to locate package containerd.io E: Couldn't find any package by glob 'containerd.io' E: Couldn't find any package by regex 'containerd.io'

编辑ubuntu源 /etc/apt/sources.list

$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.back

$ sudo vi /etc/apt/sources.list

最后增加
deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable

复制

$ sudo apt-get update

复制

Hit:1 Index of /ubuntu focal InRelease Hit:2 Index of /ubuntu focal-security InRelease Get:3 Index of linux/ubuntu/ bionic InRelease [64.4 kB] Err:3 Index of linux/ubuntu/ bionic InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8 Hit:4 Index of /ubuntu focal-updates InRelease Get:5 Index of linux/ubuntu/ focal InRelease [57.7 kB] Err:5 Index of linux/ubuntu/ focal InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8 Hit:6 Index of /ubuntu focal-backports InRelease Reading package lists... Done W: GPG error: Index of linux/ubuntu/ bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8 E: The repository 'Index of linux/ubuntu/ bionic InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. W: GPG error: Index of linux/ubuntu/ focal InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8 E: The repository 'Index of linux/ubuntu/ focal InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.

将公钥添加至服务器,即终端中输入

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys '7EA0A9C3F273FCD8'

Executing: /tmp/apt-key-gpghome.VIv8eLEwb3/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 7EA0A9C3F273FCD8
gpg: key 8D81803C0EBFCD88: 9 signatures not checked due to missing keys
gpg: key 8D81803C0EBFCD88: public key "Docker Release (CE deb) <[email protected]>" imported
gpg: Total number processed: 1
gpg:              imported: 1

复制

$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io

复制

参考:https://www.jianshu.com/p/5b7c1d02f958

添加软件源

$ sudo mkdir -p /etc/docker
$ sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://mirror.aliyuncs.com"]
}
EOF
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

复制

这里的registry-mirrors可以替换成任意源

网易的镜像地址:http://hub-mirror.c.163.com

参数双杠

1、unknown shorthand flag: ‘n’ in -name
See ‘docker run --help’.

2、unknown shorthand flag: ‘r’ in -restart
See ‘docker run --help’.

解决:
-name换为–name;-restart换为–restart

failed to solve with frontend dockerfile.v0: failed to create LLB definition:

failed to solve with frontend dockerfile.v0: failed to create LLB definition:_程序员june的博客-CSDN博客

参考:

docker安装踩坑指南(ubuntu 20.04 focal)_梦实现了吗的博客-CSDN博客

在docker的PHP镜像中安装Swoole_@日月空@的博客-CSDN博客_docker php 安装swoole

https://github.com/swoole/docker-swoole#swoole-48

docker-swoole/Dockerfile at master · swoole/docker-swoole · GitHub

【学习笔记】解决Ubuntu20.04安装Docker时,设置仓库失败问题 - 灰信网(软件开发博客聚合)

ubuntu docker相关错误记录 - IT~民工 - 博客园

docker安装elasticsearch(docker安装elk)图文详解教程 - 极客库

猜你喜欢

转载自blog.csdn.net/cxs812760493/article/details/127655190
今日推荐