mac 基于docker进行ubuntu开发配置教程

mac 基于docker进行ubuntu开发配置教程,第1张

文章目录
  • 2. 配置git
    • 2.2 配置ssh
    • 2.3 配置git公钥
  • 3. docker常用 *** 作
    • 3.1 mac手动彻底删除docker
    • 4.1 更改ubuntu18.04 软件源
    • 4.2 配置ubuntu18.04 软件环境

docker pull ubuntu:18.04 //安装下载ubuntu18.04的镜像
mkdir myDockerDir && cd myDockerDir //在宿主机(Mac)创建共享文件夹
docker run --name [Name of container] -it -v $PWD:[your_docker_dir] <imagename> /bin/bash ///运行容器,例如:docker run --name docker_ubuntu1804 -it -v $PWD:/Users/myDockerDir cc6f13ca5102 /bin/bash
${在ubuntu中进行一系列 *** 作}
exit //退出镜像
docker commit -m 'install git' -a 'zack' 3213ec381ab8 ubuntu18.04-develop //保存为新的镜像 docker commit <container-id> <repository>:<tag>
docker push  ${repository 名称} //将image推送到docker-hub
若出错,则命令改为:
  1、docker tag firstimage YOUR_DOCKERHUB_NAME/firstimage
  2、docker push YOUR_DOCKERHUB_NAME/firstimage
  3、docker login
2. 配置git
git config --global user.name "${name}" // 配置用户名
git config --global user.email "${email}" // 配置邮箱
2.2 配置ssh
sudo apt install openssh-server //安装服务器端
sudo apt install openssh-client // 安装客户端
sudo /etc/init.d/ssh restart  //重启ssh服务

可选:
3.配置ssh客户端,去掉PasswordAuthentication yes前面的#号,保存退出
udo vi /etc/ssh/ssh_config

4.配置ssh服务器,把PermitRootLogin prohibit-password改成PermitRootLogin yes,保存退出。
sudo vi /etc/ssh/sshd_config

2.3 配置git公钥
ssh-keygen -t rsa -C "coding-docker_ubuntu1804" // 运行命令后 一路enter 生成公钥

~/.ssh/id_rsa.pub文件中即为公钥,将该公钥复制到git中即可。

3. docker常用 *** 作
docker start 容器名称 //启动已有容器
docker stop 容器名称  //终止已有容器
docker cp VTK-9.1.0.tar.gz c11fc7c366b0:/Docker_Ubuntu1804/tem  //复制宿主文件到docker容器中,c11fc7c366b0为容器id
docker save db2b37ec6181 > /opt/data/mysql.tar.gz //导出镜像
docker load -i /opt/data/mysql-master.tar.gz //导入镜像

docker run --name container_ubuntu1804_develop -it -v /Users/liuzhongze/Docker_Ubuntu1804:/Docker_Ubuntu1804 567181747037 /bin/bash  //共享文件 宿主文件夹:docker文件夹
3.1 mac手动彻底删除docker
sudo rm -rf /Applications/Docker.app 
sudo rm -rf /private/var/folders/0y/frd89c5s3yx4pg6fjbn9d8j00000gn/C/com.electron.dockerdesktop //需要自己找路径
rm -rf ~/Library/Containers/com.docker.docker 
rm -rf ~/Library/Application\ Support/Docker\ Desktop 
rm -rf ~/Library/Saved\ Application\ State/com.electron.dockerdesktop.savedState 
rm -rf ~/Library/HTTPStorages/com.docker.docker 
rm -rf ~/Library/Caches/com.docker.docker 
rm -rf ~/Library/Group\ Containers/group.com.docker 
rm -rf ~/Library/Application\ Support/com.bugsnag.Bugsnag/com.docker.docker
4.1 更改ubuntu18.04 软件源
vim /etc/apt/sources.list

粘贴以下内容:

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

4.2 配置ubuntu18.04 软件环境
apt-get install sudo git vim openssh-server cmake build-essential libgl1-mesa-dev freeglut3-dev libglew-dev libsdl2-dev libsdl2-image-dev libglm-dev libfreetype6-dev 
sudo apt-get  install libproj-dev libflann-dev libssl-dev  zlib1g-dev libpng-dev  libjpeg-dev  libbz2-dev liblz4-dev uuid-dev libunwind-dev autoconf automake libtool curl make g++ unzip libcurl-dev libvtk6-dev python2.7  libgtest-dev curl python-pip

安装protobuf 3.11.0
1.安装protobuf:ubuntu下参考https://blog.csdn.net/kdchxue/article/details/81046192:

$ sudo apt-get install autoconf automake libtool curl make g++ unzip
$ git clone https://github.com/google/protobuf.git
$ cd protobuf
$ git submodule update --init --recursive
$ ./autogen.sh
$ ./configure centos安装时会报错error: C++ preprocessor “/lib/cpp” fails,可以尝试yum install glibc-headers && yum install gcc-c++

$ make
$ make check
$ sudo make install
$ sudo ldconfig # refresh shared library cache.

2.安装python版,参考https://blog.csdn.net/u013210620/article/details/81317731#linux安装:

cd protobuf/python
python setup.py build
python setup.py test
python setup.py install

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/905345.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-15
下一篇 2022-05-15

发表评论

登录后才能评论

评论列表(0条)

保存