a note when using docker locally
- when building the getting-started application provided by official site, I got a error saying,
it's normal in China that downloading files from github, so I changed the hosts file as below to acceralte the downloading.#0 138.4 node-pre-gyp ERR! install request to https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.2/napi-v6-linux-musl-x64.tar.gz failed, reason: socket hang up
- get ip for fastly.net
- get cdn for github
- modify hosts
# github 151.101.1.194 github.global.ssl.fastly.net 140.82.114.3 github.com
- deploy a mysql locally
sudo docker pull mysql sudo docker run --name mysql -e MYSQL_ROOT_PASSWORD=password -d mysql sudo docker exec -it mysql bash bash-4.4# mysql -u root -p Enter password:
note: the initial user is 'root' and password is the one you set when running this container.
another connection to mysql(I use network in this case)
issue reference
$ sudo docker network create mysql-net
# start an instance of mysql
$ sudo docker run --network mysql-net --name mysql8 -e MYSQL_ROOT_PASSWORD=password -d mysql
# connect to mysql
$ sudo docker run --network mysql-net -it --rm mysql mysql -hmysql8 -uroot -p
-
mysql 8.0.33 docker image misses some command like mysqlbinlog
the community hasn't agree on this. so I use debian instead of oracle(which is latest).
$ sudo docker pull mysql:debian
$ sudo docker run --name mysql-debian -e MYSQL_ROOT_PASSWORD=password -d mysql:debian anna@anna-KPRC-WX0:~$ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4b3059437cfa mysql:debian "docker-entrypoint.s…" 19 seconds ago Up 18 seconds 3306/tcp, 33060/tcp mysql-debian 2fccb5f7ea80 mysql "docker-entrypoint.s…" About an hour ago Up About an hour 3306/tcp, 33060/tcp mysql8 anna@anna-KPRC-WX0:~$ sudo docker exec -it mysql-debian bash root@4b3059437cfa:/# which mysqlbinlog /usr/bin/mysqlbinlog
-
check the image info(e.g. tag) in docker repository
curl -L -s 'https://registry.hub.docker.com/v2/repositories/library/mysql/tags?page_size=1024'
-
start a container as a mysql slave
write a mysql.cnf for slave and mount the volumnsudo docker run -p 3302:3306 --name mysql-slave -e MYSQL_ROOT_PASSWORD=password -d mysql:debian -v abs_path_to_conf:/etc/mysql/conf.d
-
change network config for a docker which has already been running.
- stop docker
systemctl stop docker
- modify config file
/var/lib/docker/containers/<container_id>/hostconfig.json
"PortBindings":{ "3306/tcp":[ { "HostIp":"", "HostPort":"3306" } ] }
- start docker and container
systemctl start docker
&sudo docker start <container_id>
- stop docker
-
redis
$ sudo docker ps -a
35205d9a83a3 redis "docker-entrypoint.s…" 5 months ago Exited (255) 2 weeks ago 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp redis7
$ sudo docker start 35205d9a83a3
$ sudo docker exec -it redis7 bashusing redis-cli root@35205d9a83a3:/data# redis-cli 127.0.0.1:6379>
aliyun experience
today I applied an vps on aliyun, keep a note on installation of docker-compose.
since you network is way too slow, official commad executed too slow.
$ curl -SL https://github.com/docker/compose/releases/download/v2.24.5/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
I can't find another more efficient way in short time than move the same file to remote server and continue to the following core opporations.
config image source of ali
find your accelarating address via https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors like below. it's free, btw.
and then check the 'registry mirrors' with
$ docker info
however, the speed is not fast as expected ater configuration. so I export the local images and import them on remote side.
$ sudo docker export bb0b00919cf1 > **.tar
$ docker import - pg-vecotr < pg-vector.tar
check images:
$ docker images
if the size is larger than 500, which is the limitation on aliyun,
$ split -b 400m mongo.tar -d mongo.tar. #-b block size, -d digital, mongo.tar. prefix
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义