PyCharm for remote development and debugging linux server

---Restore content begins---

Introduction:

Maybe I should also migrate to linux environment to develop.

Some small things I wrote recently, developed on wnidows and debugged on windows, are all normal. But once it is put into the linux server, it will stop working.

So what can we do to deal with the compatibility problem between windows and linux? Develop in linux, or develop in a linux environment. It looks similar, but the meaning is really different.

In linux development, that is to use the linux operating system to develop.

Developing in the Linux environment is not limited to developing in the Linux operating system. We can write code under Windows and execute it in the Linux environment.

Instead of changing the operating system, write the code directly under the windows and execute it in the linux environment.

1: Create a linux environment image

Although I have a NUC running fedora (linux), I like to deploy it in alpine-docker, and I don't want any development environment to mess up my nuc again, so I still use docker to create a new one that can be used to perform python parsing environment.

1.docerfile

from alpine:3.7
MAINTAINER jackadam<[email protected]>
#change source
# The source of the installation package is cut to the University of Science and Technology of China, and domestic access is accelerated
RUN { \
        echo 'http://mirrors.ustc.edu.cn/alpine/v3.7/main'; \
        echo 'http://mirrors.ustc.edu.cn/alpine/v3.7/community'; \
        echo 'http://mirrors.ustc.edu.cn/alpine/edge/main'; \
        echo 'http://mirrors.ustc.edu.cn/alpine/edge/community'; \
        echo 'http://mirrors.ustc.edu.cn/alpine/edge/testing'; \
    } > /etc/apk/repositories && \

# Set the default time zone to Asia / Shanghai (no Beijing optional)
        apk add --no-cache --upgrade apk-tools  openssh  tzdata&& \
    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    echo "Asia/Shanghai" > /etc/timezone && \
    apk del tzdata
#Modify root password
RUN echo root:123456 | chpasswd
#Generate KEY
RUN ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -P '' -N ''
#Allow remote login
RUN sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config
#Open port 22
EXPOSE 22

CMD /usr/sbin/sshd -D

Use this dockerfile to create a docker image

2.build.sh

echo stop container
docker stop ssh 
echo delete container
docker rm  ssh 
echo temporarily disable selinux
setenforce 0  
echo rebuild mirror
docker build -t ssh .
 echo restore enabled selinux
setenforce 1  
echo start the container
docker run -d -t --restart=always --privileged --name ssh -p 2222:22  ssh

Use this script to create the image and start the container. Because I always forget selinux, reboot, delete...

Anyway, it is convenient to use.

3. Try to log in remotely and install python

Winscp, putty, can log in to this 2222 port container normally.

The command to install python is: apk add python3

Two: configure docker, open 2375 management port

1. Modify or create /etc/docker/daemon.json

{
     " registry-mirrors " : [ " http://************.m.daocloud.io " ], #This line is to register the docker mirror server
     " graph " : " /storage/docker " , #This line is to modify the docker storage location
     " hosts " :[ " tcp://0.0.0.0:2375 " , " unix:///var/run/docker.sock " ] # This line is to open port 2375
}

In fact, only write the 2375 port that line on it. Don't forget the upper and lower braces, and there is a comma at the end of each line, but not the last line.

2. Restart docker

systemctl restart docker

3. Verify

netstat -tulnp |grep docker

It's right to see monitor 2375.

 

Three: configure the firewall, open port 2375

1. Add firewall rules, open 2375

firewall-cmd --zone=public --add-port=2375/tcp --permanent

2. Reread the rules

firewall-cmd --reload

3. Test

Make sure that 2375 has been released by the firewall.

Four:

1.

2.

3.

Fives:

1.

2.

3.

six:

1.

2.

3.

seven:

1.

2.

3.

Eight:

1.

2.

3.

Nine:

1.

2.

3.

ten:

1.

2.

3.

 

---End of recovery content---

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325209025&siteId=291194637