[Docker] 03 - Install and push to cloud
From: 31 尚硅谷 Docker 安装mysql
Docker常用安装
一、Docker安装MySQL
-
启动容器
-
进入容器
docker exec -it <container id> /bin/bash
看上去,与 docker attach 有点类似。在容器内命令行模式下,进一步操作mysql。
二、Docker安装Redis
-
启动容器
-
进入容器
docker exec -it <container id> redis-cli
本地镜像推送到云端
(1) 本地镜像准备好。
docker images mycentos
(2) 云端仓库建立好。
(3) 将镜像推送到阿里云。
第一步,登录;第二步,tag;第三步,推送。
本地镜像推送到 AWS BATCH
文档: https://docs.aws.amazon.com/zh_cn/batch/latest/userguide/batch_user.pdf
AWS Batch 在其计算环境中使用 Amazon ECS 容器实例。
自定义 Ubuntu 容器
实践出真知。
一、获取 Image
查看各路镜像,找一个官方的,拉到本地。
Ref: 修改 Docker 的默认存储路径
$sudo docker info命令中有提示:Docker Root Dir: /var/lib/docker
$ sudo docker search ubuntu -s 30 Flag --stars has been deprecated, use --filter=stars=3 instead NAME DESCRIPTION STARS OFFICIAL AUTOMATED ubuntu Ubuntu is a Debian-based Linux operating sys… 11320 [OK] dorowu/ubuntu-desktop-lxde-vnc Docker image to provide HTML5 VNC interface … 461 [OK] rastasheep/ubuntu-sshd Dockerized SSH service, built on top of offi… 247 [OK] consol/ubuntu-xfce-vnc Ubuntu container with "headless" VNC session… 226 [OK] ubuntu-upstart Upstart is an event-based replacement for th… 110 [OK] ansible/ubuntu14.04-ansible Ubuntu 14.04 LTS with ansible 98 [OK] neurodebian NeuroDebian provides neuroscience research s… 69 [OK] 1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 50 [OK] ubuntu-debootstrap debootstrap --variant=minbase --components=m… 44 [OK] jeffrey@unsw-ThinkPad-T490:/$
$ sudo docker pull ubuntu:18.04 Using default tag: latest latest: Pulling from library/ubuntu e6ca3592b144: Pull complete 534a5505201d: Pull complete 990916bd23bb: Pull complete Digest: sha256:cbcf86d7781dbb3a6aa2bcea25403f6b0b443e20b9959165cf52d2cc9608e4b9 Status: Downloaded newer image for ubuntu:latest docker.io/library/ubuntu:latest
$ sudo docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest bb0eaf4eee00 6 hours ago 72.9MB
二、基本配置
安装 vim,因为默认root,所以不需要sudo。
apt-get update && apt-get install vim -y
echo "" echo "############################" echo "Dev Environment" echo "############################" echo "" #### Install dependencies sudo apt -y install build-essential checkinstall cmake pkg-config yasm sudo apt -y install git gfortran sudo apt -y install libjpeg8-dev libpng-dev sudo apt -y install software-properties-common sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main" sudo apt -y update sudo apt -y install libjasper1 sudo apt -y install libtiff-dev sudo apt -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev sudo apt -y install libxine2-dev libv4l-dev cd /usr/include/linux sudo ln -s -f ../libv4l1-videodev.h videodev.h cd "$cwd" sudo apt -y install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev sudo apt -y install libgtk2.0-dev libtbb-dev qt5-default sudo apt -y install libatlas-base-dev sudo apt -y install libfaac-dev libmp3lame-dev libtheora-dev sudo apt -y install libvorbis-dev libxvidcore-dev sudo apt -y install libopencore-amrnb-dev libopencore-amrwb-dev sudo apt -y install libavresample-dev sudo apt -y install x264 v4l-utils #### Optional dependencies sudo apt -y install libprotobuf-dev protobuf-compiler sudo apt -y install libgoogle-glog-dev libgflags-dev sudo apt -y install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen #### Others sudo apt-get install htop sudo apt-get install cmake sudo apt-get install git sudo apt install unzip sudo apt-get install vim sudo apt-get install curl #### python dependencies. sudo apt-get install python-pip sudo pip install future
Linux下命令补全工具bash-completion
apt-get install -y bash-completion
下载 get-pip.py,然后执行:
sudo apt install python3-pip
# pip安装可能需要手动
python get-pip.py
pip install future
三、保存镜像
自己做一个配置了基本命令的docker image。赶紧保存下来,毕竟目前是临时数据和状态。
Ref: Docker(七) - commit 将容器保存为镜像
sudo docker commit -a 'jeffrey' -m 'install.sh done.' e6b4674985cd ubuntu:18.04-env
四、数据共享
在docker环境中做开发,文件的互传通过相互间挂载来执行,详见:[Docker] 01 - Container
End.