关于这podman啊,一天天的,都在说要替换docker,然后也是大家各种说怎么弄怎么弄,教你安装podman之后,alias docker="podman" ,然后pip3 install podman-compose,再alias一条 alias docker-compose="podman-compose",说的这样好象就差不多了
确实,正常情况下,或者在linux\wsl的情况下,应该是差不多的,虽然部分命令不一样,但看一看参数,基本上也就过了。。。
mac下确实有一个大坑。因为mac其实是不支持container这玩意的。所以不管是docker也好,谁也好,都得装虚拟机。。。
早期podman的教程大多是让你安装一个ubuntu出的multipass,然后再各种连接,用podman连接远程(就是multipass出来的ubuntu虚拟机中安装一个podman)。。。手续也烦,教程也复杂。所以官方升级后出了一个简化版本:podman machine init/podman machine start。然后就可以各种操作了,确实方便很多。
然而问题也正是发生在这里。
> 且看我一步步操作
* brew update && brew install podman
* 正常更新,但由于有部分文件在raw.githubusercontent.com上,遇到这个,代表你只能用代理 了。于是ctrl+c
* export http_proxy=127.0.0.1:1087;export https_proxy=127.0.0.1:1087;export all_proxy=127.0.0.1:1080
* 再次执行:brew update&& brew install podman
*顺利执行完
* podman machine init && podman machine start
* 没问题,但这里要吐槽一下,安装的是fedora。。。好吧,我忍了。我纠结的是,为什么不能选择宿主操作系统?
* podman pull mysql
* 问题就出来这里,拉包的时候,报错
```
podman create --name=pl-and-si-mysql-db --label io.podman.compose.config-hash=123 --label io.podman.compose.project=pipeline_combined_db --label io.podman.compose.version=0.0.1 --label com.docker.compose.project=pipeline_combined_db --label com.docker.compose.project.working_dir=/Users/gouki/Desktop/SC-REDBACK-main/database/pipeline_combined_db --label com.docker.compose.project.config_files=docker-compose.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=pl-and-si-db -e MYSQL_DATABASE=database -e MYSQL_ROOT_PASSWORD=password -v pipeline_combined_db_pl_and_si_database_folder:/var/lib/mysql -v /Users/gouki/Desktop/SC-REDBACK-main/database/pipeline_combined_db/allInOne.sql:/docker-entrypoint-initdb.d/1.sql --net pipeline_combined_db_default --network-alias pl-and-si-db -p 3306:3306 --restart always --cpus 0.4 -m 350m mysql:latest
Resolving "mysql" using unqualified-search registries (/etc/containers/registries.conf.d/999-podman-machine.conf)
Trying to pull docker.io/library/mysql:latest...
Error: initializing source docker://mysql:latest: pinging container registry registry-1.docker.io: Get "https://registry-1.docker.io/v2/": proxyconnect tcp: dial tcp 127.0.0.1:1087: connect: connection refused
```
咦,他走了代理 ,但被拒绝?不可能啊,我前面下载软件的时候不是还好好的么,难道是代理错误?于是我新开一个shell窗口,再次执行,仍然是同样的错误,这回就发现问题了,因为新的shell窗口我env|grep -i proxy的时候,返回为空,当前进程没有任何一个proxy参数
有人这样回复:
```
The proxy is set correctly: proxyconnect tcp: dial tcp 127.0.0.1:7890: connect: connection refused
The problem is that your proxy is listening on 127.0.0.1. Obviously 127.0.0.1 inside the VM is a different address and therefore it cannot connect to the proxy on you actual host.
If you set http_proxy=socks5://host.containers.internal:7890
before you run podman machine init
it should work.
Maybe podman should just s/127.0.0.1/host.containers.internal
and s/localhost/host.containers.internal
automatically when it copies the proxy value from the host.
```
感情是你只要machine init的之前用了代理 ,init完后。针对vm的参数就变了。于是下面就有人说,你可以这样:
```
I just test it and I think you are right, but I don't know why http_proxy=socks5://host.containers.internal:7890 podman machine init
this command still hit the same error but it works as expected when I add 127.0.0.1 host.containers.internal
to my host file
however it works now
add item blow to host file
127.0.0.1 host.containers.internal
and change proxy to
http_proxy=socks5://host.containers.internal:7890
then everything works fine
much thanks @Luap99 for your help and I close this issues for the problem is solved, but I still stay concerned if some day podman can do this itself and no need to change proxy setting
```
呵呵,这么麻烦?我还是新建一个shell窗口:podman machine stop && podman machine init && podman machine start吧。
然后,podman pull mysql,一切正常~
至此搞定。
> 假装内容支持markdown,因为新模板在寻找中,现在的html所见所得,估计会全部改成markdown,先尝试一下。
版权协议, 要求署名、非商业和保持一致. 本站欢迎任何非商业应用的转载, 但须注明出自"