英文:
Setting Up Remote Docker Daemon on Linux for Development on Macbook
问题
我目前面临一些挑战,需要一些指导。我的情况如下:由于我在Macbook M1上遇到性能问题,我无法有效地使用Docker来进行我的当前项目。因此,我已经将开发转移到了Linux机器,但我真的很想在我的Macbook上编写代码。
我想要实现的目标是:我希望在我的Linux笔记本上建立一个远程Docker守护程序,我可以从我的Macbook上访问并使用。这样,我就可以在我的Macbook上编写代码,同时利用我的Linux机器的Docker功能。
我已经进行了一些研究,似乎这应该是可能的,但我不太确定从哪里开始。
我需要进行哪些配置以确保它是安全的,并且可以从远程机器访问,并从我的Macbook连接到远程守护程序?
我对使用Docker相对不熟悉,尤其是在这种分布式设置下,因此非常感谢任何详细的步骤或解释。如果有人有类似设置的经验,或者可以指向相关资源,我将非常感激。
英文:
I'm facing a bit of a challenge here and could use some guidance. Here's my situation: Due to performance issues on my Macbook M1, I'm unable to use Docker effectively for my current project. So, I've shifted my development to the Linux machine, but I'd really prefer to code on my Macbook.
Here's what I'm aiming for: I want to establish a remote Docker daemon on my Linux laptop that I can access and work with from my Macbook. This way, I can write code on my Macbook while utilizing the Docker capabilities of my Linux machine.
I've done some research, and it seems like this should be possible, but I'm not quite sure where to start.
What configurations do I need to make to ensure it's secure and accessible from remote machines and connect to the remote deamon from my macbook?
I'm relatively new to working with Docker, especially in this kind of distributed setup, so any detailed steps or explanations would be greatly appreciated. If anyone has experience with a similar setup or can point me to some relevant resources, I'd be extremely grateful.
答案1
得分: 1
我有一台Ubuntu机器和一台Mac,成功地按照以下步骤设置了连接:
a) 在Ubuntu上
1) 运行sudo vim /etc/systemd/system/multi-user.target.wants/docker.service
将[ExecStart=/usr/bin/dockerd]一行替换为:
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375"
2) 退出vim并运行
sudo systemctl daemon-reload
sudo systemctl restart docker.service
b) 在Mac上
1) 在一个终端中,运行以下命令设置端口转发:
ssh -L 2375:0.0.0.0:2375 ubuntu "echo 2375:0.0.0.0:2375; sleep inf"
2) 在另一个终端中运行
export DOCKER_HOST=tcp://localhost:2375
docker ps -a
Ubuntu和Mac之间的通信通过安全壳(Secure Shell)进行。
只需稍加注意,就不应该有安全性/性能问题。
英文:
I have a Ubuntu machine and a mac, managed to set it up with following steps :
a) On Ubuntu
1) sudo vim /etc/systemd/system/multi-user.target.wants/docker.service
Replace [ExecStart=/usr/bin/dockerd] line with :
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375"
2) Exit vim and run
sudo systemctl daemon-reload
sudo systemctl restart docker.service
b) On MacOS
1) In one Terminal, run following to setup portforwarding:
ssh -L 2375:0.0.0.0:2375 ubuntu "echo 2375:0.0.0.0:2375; sleep inf"
2) In another Terminal, run
export DOCKER_HOST=tcp://localhost:2375
docker ps -a
The communication between Ubuntu and Mac is thru Secure Shell.
With a little more care, there should be no security/performance issue.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论