根据https://blog.csdn.net/abcdrachel/article/details/95593584博客安装好所需环境后,首先我stop了该镜像,然后start该镜像,接着通过ip+端口号访问该容器,遇到如下情况:

Unable to contact settings server

Failed to connect to socket /tmp/dbus-lam2d65eVO:Connection refused

点击OK后,出现如下对话框

再点击Quit后,呈现如下界面

解决办法:

首先在该容器中运行如下语句:

ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target

然后使用下面语句进入/root/.bahsrc该文件:

vi /root/.bashrc

接着将anaconda3的环境变量注释了

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
#source $STARTUPDIR/generate_container_user
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
export JAVA_HOME=/usr/local/src/jdk/jdk1.8.0_141
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lii
b/tools.jar
export PATH=$PATH:$JAVA_HOME/bin


# added by Anaconda3 installer
#export PATH="/root/anaconda3/bin:$PATH"
~                                                                               
"~/.bashrc" 21L, 527C

这时退出容器id,然后stop +容器id,再start+容器id,即可通过ip+端口号就可登录网页版了。

[docker@localhost ~]$ docker exec -it f6dfd8a733f4 /bin/bash
[root@hostname_1 ~]# vi /root/.bashrc
[root@hostname_1 ~]# exit
exit
[docker@localhost ~]$ docker stop f6dfd8a733f4
f6dfd8a733f4
[docker@localhost ~]$ docker start f6dfd8a733f4
f6dfd8a733f4

注:虽然已经可登录网页版了,但是却存在一个问题,那就是在/root/.bashrc中注释了anaconda3的环境变量后,anaconda3不能再使用,如果想使用anaconda3,则需要再次进入/root/.bashrc中,取消该注释即可再使用anaconda3

在未更改/root/.bashrc中anaconda3的环境变量,我们先保存该容器

首先给通过该容器生成一个镜像:

[docker@localhost ~]$ docker ps
CONTAINER ID        IMAGE                                  COMMAND                  CREATED             STATUS              PORTS                              NAMES
f6dfd8a733f4        ibus-wps-jdk-ssh-userhadoop11          "/dockerstartup/vnc_…"   6 hours ago         Up 22 minutes       5901/tcp, 0.0.0.0:9035->6901/tcp   text_classification_5
4e7b132bcccd        ibus-wps-jdk-ssh-userhadoop11:latest   "/dockerstartup/vnc_…"   23 hours ago        Up 22 hours         5901/tcp, 0.0.0.0:9029->6901/tcp   text_classification_2
0ff29396432f        ibus-wps-jdk-ssh-userhadoop11:latest   "/dockerstartup/vnc_…"   25 hours ago        Up 22 hours         5901/tcp, 0.0.0.0:9027->6901/tcp   text_classification_1
9ef5690f7a49        ibus-wps-jdk-ssh-userhadoop11:latest   "/dockerstartup/vnc_…"   3 days ago          Up 3 days           5901/tcp, 0.0.0.0:9018->6901/tcp   face3
[docker@localhost ~]$ docker commit -a "limt" -m "original enviroment" f6dfd8a733f4  text_classification_5
sha256:da10e6bf6d7f3db882bd30465b2b17c3ce339f4a504e08bd9ad5fdac02698acc

查看了一下生成的镜像,竟然没有名字,好吧自己加一个名字

[docker@localhost education]$ docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
<none>                          <none>              da10e6bf6d7f        4 minutes ago       6.21GB
ibus-wps-jdk-ssh-userhadoop11   latest              6376b9526a4d        9 months ago        2.71GB
[docker@localhost education]$ docker tag da10e6bf6d7f text_classification_start:latest
[docker@localhost education]$ docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
text_classification_start       latest              da10e6bf6d7f        7 minutes ago       6.21GB
ibus-wps-jdk-ssh-userhadoop11   latest              6376b9526a4d        9 months ago        2.71GB

然后保存该镜像

[docker@localhost education]$ docker save text_classification_start -o /home/docker/education/text_classification_start.tar

给该容器上次代码、数据等文件

[docker@localhost education]$ docker cp /home/docker/education/rachel/text_classification/code.zip f6dfd8a733f4:/root/Desktop/项目脚本/
[docker@localhost education]$ docker cp /home/docker/education/rachel/text_classification/data.zip f6dfd8a733f4:/root/Desktop/项目数据/

进入对应的文件加下,进行解压,解压时发现没有unzip命令

进行安装

yum -y install unzip zip
unzip data.zip
unzip code.zip

然后打开pycharm,选择open,然后找到code的存放目录,打开

现在设置pycharm,选择file中的setting

选择show all,出现对话框后,点解+

再弹出对话框,选择如下

 

附上:anaconda的其他版本镜像

https://repo.continuum.io/archive/index.html

https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐