直接通过docker hub上的centos镜像安装centos
docker search centos[docker@localhost education]$ docker search centosNAME DESCRIPTION STARSOFFICIAL AUTOMATEDcentos The official build of CentOS. 5433[OK]ansible/centos7-ansible Ansible on Centos7121 [OK]jdeathe/centos-ssh CentOS-6 6.10 x86_64 / CentOS-7 7.6.1810 x86鈥 110 [OK]consol/centos-xfce-vnc Centos container with "headless" VNC session鈥 91 [OK]centos/mysql-57-centos7 MySQL 5.7 SQL database server 57 imagine10255/centos6-lnmp-php56 centos6-lnmp-php5657 [OK]tutum/centos Simple CentOS docker image with SSH access44 centos/postgresql-96-centos7 PostgreSQL is an advanced Object-Relational 鈥 37 kinogmt/centos-ssh CentOS with SSH 27 [OK]centos/php-56-centos7 Platform for building and running PHP 5.6 ap鈥 20 guyton/centos6 From official centos6 container with full up鈥 10 [OK]pivotaldata/centos-gpdb-dev CentOS image for GPDB development. Tag names鈥 10 drecom/centos-ruby centos ruby 6 [OK]mamohr/centos-java Oracle Java 8 Docker image based on Centos 7 3 [OK]darksheer/centos Base Centos Image -- Updated hourly 3 [OK]pivotaldata/centos Base centos, freshened up a little with a Do鈥 3 pivotaldata/centos-mingw Using the mingw toolchain to cross-compile t鈥 2 miko2u/centos6 CentOS6 鏃ユ湰瑾炵挵澧 2 [OK]pivotaldata/centos-gcc-toolchain CentOS with a toolchain, but unaffiliated wi鈥 1 indigo/centos-mavenVanilla CentOS 7 with Oracle Java Developmen鈥 1 [OK]mcnaughton/centos-base centos base image 1 [OK]blacklabelops/centosCentOS Base Image! Built and Updates Daily!1 [OK]pivotaldata/centos7-dev CentosOS 7 image for GPDB development 0 smartentry/centos centos with smartentry0 [OK]pivotaldata/centos6.8-devCentosOS 6.8 image for GPDB development 0
docker pull centos[docker@localhost education]$ docker pull consol/centos-xfce-vncUsing default tag: latestlatest: Pulling from consol/centos-xfce-vncaeb7866da422: Pull complete c3948401e05b: Pull complete 4d424b4f2455: Pull complete ce55375c3860: Pull complete ded4c99659f8: Pull complete 50cee5e65736: Pull complete c14af47ad3e4: Pull complete b6fd4b34e8c0: Pull complete 738e2295aff1: Pull complete d75f5e3b00c7: Pull complete 396b3796f97e: Pull complete f484ecf38739: Pull complete c963ac501b0a: Pull complete 0be02427f629: Pull complete f4a8501defa7: Pull complete Digest: sha256:785d27ec7508182db3bcfd670d4a92e00297211ab8ee56fa8c573bfc58f5441aStatus: Downloaded newer image for consol/centos-xfce-vnc:latest
安装好centos后
docker中进入容器:
#docker run -it -p 10000:6901 centos:latest /bin/bash[docker@localhost education]$ docker run -d -P --name face1 consol/centos-xfce-vnc5f0292067f7df2aad437444d7c741225086576f0046e604855ada7597ce3c042[docker@localhost education]$ docker ps -aCONTAINER ID IMAGECOMMAND CREATED STATUS PORTS NAMES5f0292067f7d consol/centos-xfce-vnc "/dockerstartup/vnc_鈥 10 seconds agoUp 10 seconds 0.0.0.0:9001->5901/tcp, 0.0.0.0:9000->6901/tcp face1f32a30e8fdc4 centos:latest "/bin/bash" 24 hours ago Up 6 hours0.0.0.0:10000->80/tcp reverent_shockley#然而我这样进入的时候,却出现下面的问题[docker@localhost education]$ docker psCONTAINER ID IMAGECOMMAND CREATED STATUS PORTS NAMES5f0292067f7d consol/centos-xfce-vnc "/dockerstartup/vnc_鈥 6 minutes ago Up 6 minutes 0.0.0.0:9001->5901/tcp, 0.0.0.0:9000->6901/tcp face1[docker@localhost education]$ docker exec -it 5f0292067f7d /bin/bashUSER_ID: 1000, GROUP_ID: 0nss_wrapper location: /usr/lib64/libnss_wrapper.sobash-4.2$ exitexit
[docker@localhost education]$ docker run -it -P consol/centos-xfce-vnc:latest /bin/bashUSER_ID: 1000, GROUP_ID: 0nss_wrapper location: /usr/lib64/libnss_wrapper.so------------------ update chromium-browser.init ------------------... set window size 1280 x 1024 as chrome window size!------------------ change VNC password ------------------------------------ start noVNC ---------------------------------------------- start VNC server ------------------------remove old vnc locks to be a reattachable containerno locks presentstart vncserver with param: VNC_COL_DEPTH=24, VNC_RESOLUTION=1280x1024...start window manager...------------------ VNC environment started ------------------VNCSERVER started on DISPLAY= :1 => connect via VNC viewer with 172.17.0.2:5901noVNC HTML client started:=> connect via http://172.17.0.2:6901/?password=...------------------ EXECUTE COMMAND ------------------Executing command: '/bin/bash'USER_ID: 1000, GROUP_ID: 0nss_wrapper location: /usr/lib64/libnss_wrapper.sobash-4.2$ [docker@localhost education]$ docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES5f0292067f7d consol/centos-xfce-vnc"/dockerstartup/vnc_鈥 About an hour ago Up About an hour 0.0.0.0:9001->5901/tcp, 0.0.0.0:9000->6901/tcp face1
在这里琢磨了半天,以为出错了,过后才知道,这种图形化界面的不是这样打开的
浏览器网页访问桌面地址:http://服务器IP:9000,浏览器中输入http://192.168.1.123:9000/ ,我的docker机器是192.168.1.123
密码为:vncpassword
详细参数及更多使用方法看官网介绍:/r/consol/centos-xfce-vnc/
然后出现了下面的界面:
在该系统中打开终端,下载及安装anaconda3
wget https://mirrors.tuna./anaconda/archive/Anaconda3-5.1.0-Linux-x86_64.shbash Anaconda3-5.1.0-Linux-x86_64.sh
然而修改环境变量的时候出现问题了,anaconda3存放地址为:/headless/anaconda3/bin
使用语句 vim /etc/profile 修改环境变量
"/etc/profile" E212: Cant't open file for writing
原来是权限不够,回去关闭容器,然后重启加参数--privileged=true
[docker@localhost education]$ docker ps CONTAINER ID IMAGECOMMAND CREATED STATUS PORTS NAMES5f0292067f7d consol/centos-xfce-vnc "/dockerstartup/vnc_鈥 2 hours ago Up 2 hours0.0.0.0:9001->5901/tcp, 0.0.0.0:9000->6901/tcp face1[docker@localhost education]$ docker ps -aCONTAINER ID IMAGECOMMAND CREATED STATUS PORTS NAMES5f0292067f7d consol/centos-xfce-vnc "/dockerstartup/vnc_鈥 2 hours ago Up 2 hours 0.0.0.0:9001->5901/tcp, 0.0.0.0:9000->6901/tcp face1f32a30e8fdc4 centos:latest "/bin/bash" 26 hours ago Exited (137) 2 hours ago reverent_shockley[docker@localhost education]$ docker stop 5f0292067f7d5f0292067f7d
本来以为重启加上这个参数就好,结果发现run命令是重新生成一个新容器,so我只好重新生成一个容器,然后加上该参数
[docker@localhost education]$ docker run -d -P --privileged=true --name face2 consol/centos-xfce-vnc502a4392c98098db1c779037e4203c7a410168e66421c25452e32eae6b055ca9[docker@localhost education]$ docker psCONTAINER ID IMAGECOMMAND CREATED STATUS PORTS NAMES502a4392c980 consol/centos-xfce-vnc "/dockerstartup/vnc_鈥 6 seconds ago Up 5 seconds 0.0.0.0:9011->5901/tcp, 0.0.0.0:9010->6901/tcp face2
最后发现这个centos里除了以下几项是不能修改环境变量的