云平台虚拟机修改root口令

1. 停止虚拟机
virsh destroy instance-000007c4
2. 挂载虚拟机的磁盘文件:
qemu-nbd –c /dev/nbd15 /dsx01/instances/instance-000007c4
kpartx –a /dev/nbd15
mkdir –p /tmp/tmpClone
mount /dev/mapper/nbd15p1 /tmp/tmpClone
3. 生成root用户的密码,这里密码就是root,(虚拟机原密码不是root)
openssl passwd -1 -salt $(< /dev/urandom tr -dc '[:alnum:]' | head -c 32) 4. 将生成的字符串替换/etc/shadow文件中root的用户密码(替换整个第二个分段): 保存并退出。 5. 卸载磁盘文件: umount /dev/mapper/nbd15p1 kpartx –d /dev/nbd15 qemu-nbd –d /dev/nbd15 6. 打开虚拟机并登陆 virsh start instance-000007c4 ssh root@$ip

docker学习笔记01

1、we can show a list of current containers using the docker ps -a command.
By default, when we run just docker ps, we will only see the running containers.
When we specify the -a flag, the docker ps command will show us all containers,
both stopped and running.
You can also use the docker ps command with the -l flag to show the last
container that was run, whether it is running or stopped.

2、Starting a stopped container
docker start bob_the_container(your container name).
We could also refer to the container by its container ID instead.
docker start aa3f365f0f4e

3、how to daemonized containers:
docker run –name daemon_dave -d ubuntu /bin/sh -c “while ↩
true; do echo hello world; sleep 1; done”
see what happen inside a docker:
docker logs daemon_dave
docker logs -f daemon_dave
docker logs -ft daemon_dave (add timestamps)

4、inspect docker’s process
docker top daemon_dave
docker inspect –format ‘{{ .NetworkSettings.IPAddress }}’

5、delete a container
docker rm 80430f8d0921
delete all containers
docker rm `docker ps -a -q`