docker 學習筆記2

docker backup 備份
sudo docker image_name > backupname.tar
sudo docker save –outpu backupname.tar image_name
sudo docker save -o backupname.tar image_name

docker recovery 還原
sudo docker load < backupname.tar.gz
sudo docker load –input backupname.tar

下載image 來修改
sudo docker pull rastasheep/ubuntu-sshd:16.04
sudo docker run -it –name=sshdtest rastasheep/ubuntu-sshd:16.04 /bin/bash
apt-get update; apt-get install -f -y vim net-tools htop
vi /run.sh
#!/bin/bash
/usr/sbin/sshd -D &

chmod +x /run.sh

======
安裝和設定
apt-get install software-properties-common
add-apt-repository ppa:ondrej/php
apt-get purge `dpkg -l | grep php| awk ‘{print $2}’ |tr “\n” ” “`
apt-get update
apt-get install zip unzip mysql-server apache2 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-mbstring php-xdebug libapache2-mod-php5.6 php5.6-mcrypt php5.6-mysql php5.6-xml
php -v
—–
php7.2 可以移除或是設定切換
apt-get purge 7.2

切換 5.6到7.0(7.2)
From php5.6 to php7.0:

Apache:

sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart

CLI:

sudo update-alternatives –set php /usr/bin/php7.0

From php7.0 to php5.6:

Apache:

sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart

CLI:

sudo update-alternatives –set php /usr/bin/php5.6

sudo docker run -it ubuntu:16.04 /bin/bash
apt-get update
apt-get install vim openssh-server net-tools htop

建立執行的目錄並且執行
mkdir -p /var/run/sshd
/usr/sbin/sshd -D &

確認服務和連接埠
netstat -tunlp

讓Root可以登入
cd /etc/ssh
vi sshd_config
PermitRootLogin prohibit-password ==>PermitRootLogin yes

sed -ri ‘s/^session\s+required\s+pam_loginuid.so$/session optional pam_loginuid.so/’ /etc/pam.d/sshd

產生key 並給root使用
mkdir ~/.ssh
cd /root/.ssh
ssh-keygen -t rsa
cat id_rsa.pub

vi /run.sh
#!/bin/bash
/usr/sbin/sshd -D &

chmod +x /run.sh

sudo docker commit ID name:tag

======
sudo docker pull rastasheep/ubuntu-sshd:16.04
sudo docker run -it –name=sshdtest rastasheep/ubuntu-sshd:16.04 /bin/bash
apt-get update; apt-get install -f -y vim net-tools htop
vi /run.sh
#!/bin/bash
/usr/sbin/sshd -D &

chmod +x /run.sh



无觅相关文章插件,快速提升流量

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *

*