Write the Code. Change the World.

12月 19

操作

docker-compose build 

这会根据你的 Docker Compose 文件中的定义构建每个服务的镜像。

# 重命名镜像(其实,是搞了个新的引用)
docker tag old-image-name:old-tag new-image-name:new-tag

这个命令会创建一个新的标签为 new-image-name:new-tag 的镜像,并使其指向原始镜像 old-image-name:old-tag。 实际上,这并没有重命名原始镜像,而是在 Docker 中创建了一个新的标签,指向相同的镜像 ID。

确保 old-image-name:old-tag 存在于本地镜像仓库,否则 Docker 将会从远程仓库下载该镜像。

# 删除旧的引用(如果需要这么做的话)
docker rmi old-image-name:old-tag

请注意,docker rmi 只会删除标签,而不会删除镜像本身。如果这个标签是唯一指向该镜像的标签,那么整个镜像将被删除。

# 导出镜像
docker save -o output.tar image_name:tag
  • -o 参数指定输出的文件名。
  • image_name:tag 是要导出的 Docker 镜像的名称和标签。

其他 docker 环境使用。

docker load -i output.tar

阅读全文 >>

12月 18

redis Connection refused

redis 容器自身,对 redis 的操作(连接使用)都 ok。 宿主机或其他容器连接 redis 总是报 Connection refused 错误。这里使用了 redis.conf。 将 redis.conf 的 bind 修改如下。

# 修改 redis.conf bind (默认是 bind 127.0.0.1 -::1)
bind 0.0.0.0 -::1

# 重启 redis
docker restart xxx(redis 容器 id)

重点

其他容器连接 redis 时,host 可以写 redis 这个和 docker-compose.yaml 中配置的 service 相对应。这个并不是容器名。连接 mysql 也可以这样。

services:
  mysql: 
    …
  redis:
    …

redis 其他配置

**docker-compose.yaml 中

# volume 配置 (其中,宿主机的 redis.conf 不存在,就会使用默认的 redis.conf)
# 这里主要三个方面:配置文件、数据、日志
    volumes:
    - ./conf/redis/redis.conf:/etc/redis/redis.conf
    - ${DATA_DIR}/redis:/data:rw
    - ${LOG_DIR}/redis:/logs
# 设置密码启动 redis**
# 123456 是 redis 密码
command: redis-server /etc/redis/redis.conf --requirepass "123456"

redis.conf 配置

配置项 描述
bind 指定本机网卡对应的IP地址,限制本机访问,默认 bind 127.0.0.1
daemonize 指定是否为守护进程方式运行,默认值为no
logfile 指定日志文件路径,默认值为 logfile ’ ', 默认为控制台打印,并没有日志文件生成
appendonly 是否开启持久化,默认值为 no

当 daemonize 设置了yes,表示redis在后台运行,当执行 docker-compose 执行启动 redis 进程时,docker 发现自己无事可做,容器自动结束,所以导致 redis 启动失败。

appendonly 为 yes 时,volume 需要配置 :rw,指定可写可读。

容器启动后设置密码

# 找到容器 id
docker ps

# 进入容器
docker exec -it xxx(redis 容器 id-前三位即可) bash

# 进入 redis
redis-cli

# redis 使用 (如果没设置密码,可以使用了。如果设置了密码,则提示 no auth)
redis get key

# 可以查看密码信息
config get requirepass

# 设置密码
config set requirepass yourPassword

# 输入密码
auth yourPassword

# 也可以在连接的时候带上密码
redic-cli -a yourPassword

阅读全文 >>

12月 18

docker 网络

常用命令

# 显示网络
docker network ls

# 查看某个网络信息
docker network inspect xxx

# 删除网路
docker network rm xxx

# 批量删除网络
docker network rm $(docker network ls -q)

批量删除网络,有默认的三个网络是不能删除的。无论是批量删,还是单独删,都不可以。这三个网络是 bradge、host、none

NETWORK ID     NAME      DRIVER    SCOPE
a0457db48e55   bridge    bridge    local
f07f326dbd2b   host      host      local
437d811528b0   none      null      local

阅读全文 >>

12月 17

操作

# 先安装依赖
yum install -y yum-utils device-mapper-persistent-data lvm2

# 添加阿里云仓库
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

# 安装
yum -y install docker-ce

# 启动
systemctl start docker

# 设置开机自启动
systemctl enable docker

# docker info

再来安装 docker-compose

打开 https://github.com/docker/compose/tags 选择想要的版本,点击进去。


这里我选择的 v2.23.3,打开后的链接是这个。

https://github.com/docker/compose/releases/tag/v2.23.3

选择对应系统的文件,我这里选择的是 docker-compose-linux-x86_64


下载

cd /usr/local/src

wget  https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-linux-x86_64

mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

docker-compose --version

ubuntu 安装 docker

移除旧版本

如果你已经安装了旧版本的 Docker,首先卸载旧版本:

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

安装依赖包

sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

添加 Docker 的官方 GPG 密钥

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

设置 Docker 的稳定版存储库

echo "deb [arch=amd64 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 Engine

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io

验证安装

运行以下命令验证 Docker 是否正确安装:

sudo docker run hello-world

将用户添加到 docker 用户组

为了避免在每次运行 Docker 命令时都需要使用 sudo,可以将当前用户添加到 docker 用户组:

sudo usermod -aG docker $USER

请注意,在更改用户组后,你可能需要注销并重新登录才能使更改生效。

安装 Docker Compose

下载 Docker Compose 的二进制文件:

sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

授予执行权限:

sudo chmod +x /usr/local/bin/docker-compose

验证 Docker Compose 是否正确安装:

docker-compose --version

阅读全文 >>

12月 17

mac docker 配置国内镜像

通过 docker 客户端工具。点击设置->Docker Engine。增加以下配置。

{
  …,
  "registry-mirrors": [
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com",
    "https://docker.mirrors.ustc.edu.cn"
  ]
}

点击 Apply & Restart 按钮,保存并重启。

# 查看
docker info

感觉用了镜像速度也那样。

阅读全文 >>

12月 14

在自己的服务器环境使用语音转视频,需要配置 ice server。而这个玩意先得创建通信资源。创建通信资源,在后台就可以实现。ice server 可以使用编程语言去获取。

相关文档

https://learn.microsoft.com/en-us/azure/ai-services/speech-service/text-to-speech-avatar/what-is-text-to-speech-avatar

https://github.com/Azure-Samples/cognitive-services-speech-sdk/blob/master/samples/js/browser/avatar/README.md

https://learn.microsoft.com/zh-cn/azure/communication-services/quickstarts/relay-token?pivots=programming-language-python#getting-the-relay-configuration

代码

这里以 python 来获取。只需要准备好连接字符串(endpoint)就好,这个就是需要去后台创建通信资源。

# issue-relay-tokens.py
from azure.communication.networktraversal import CommunicationRelayClient
from azure.identity import DefaultAzureCredential
from azure.communication.identity import CommunicationIdentityClient

# You can find your endpoint and access token from your resource in the Azure Portal
connection_str = "endpoint=https://xxxx.communication.azure.com/;accesskey=xxxx"
endpoint = "https://xxxx.communication.azure.com/"

# To use Azure Active Directory Authentication (DefaultAzureCredential) make sure to have
# AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET as env variables.
# We also need Identity client to get a User Identifier
# identity_client = CommunicationIdentityClient(endpoint, DefaultAzureCredential())
# relay_client = CommunicationRelayClient(endpoint, DefaultAzureCredential())

#You can also authenticate using your connection string
identity_client = CommunicationIdentityClient.from_connection_string(connection_str)
relay_client = CommunicationRelayClient.from_connection_string(connection_str)

identity_client.create_user()

relay_configuration = relay_client.get_relay_configuration()

for iceServer in relay_configuration.ice_servers:
    assert iceServer.username is not None
    print('Username: ' + iceServer.username)

    assert iceServer.credential is not None
    print('Credential: ' + iceServer.credential)

    assert iceServer.urls is not None
    for url in iceServer.urls:
        print('Url:' + url)

执行 python .\issue-relay-tokens.py,如果配置都正确,就会得到 ice 相关信息。

Username: xxx1
Credential: cre1
Url:stun:relay.communication.microsoft.com:3478
Url:turn:relay.communication.microsoft.com:3478
Username: xxx2
Credential: cre2
Url:stun:20.202.255.225:3478
Url:turn:20.202.255.225:3478

转换截图

阅读全文 >>

12月 13

通过文字输入,输出视频+语音虚拟形象输出。可以尝试尝试。

使用微软 Speech Studio

样例
https://speech.microsoft.com/portal/talkingavatar

训练声音
https://speech.microsoft.com/portal/customvoice/overview

精简版训练
https://learn.microsoft.com/zh-cn/azure/ai-services/speech-service/custom-neural-voice-lite

申请授权
https://speech.microsoft.com/portal/customvoice/accessrequirement

阅读全文 >>