Docker常用命令

1. docker版本
hduser@hadoop:~/Desktop$ sudo docker version
Client:
 Version:      17.04.0-ce
 API version:  1.28
 Go version:   go1.7.5
 Git commit:   4845c56
 Built:        Mon Apr  3 18:01:08 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.04.0-ce
 API version:  1.28 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   4845c56
 Built:        Mon Apr  3 18:01:08 2017
 OS/Arch:      linux/amd64
 Experimental: false
2. 容器的使用
    a. 打开容器
    Error response from daemon: Container be7db269e06c733263a6762b072e214e68d9547fef706164e5a829f116bb0f32 is not running
    先启动
    hduser@hadoop:~$ sudo docker start master slave01 slave02
    master
    slave01
    slave02
    hduser@hadoop:~$ 
    再打开
    hduser@hadoop:~$ sudo docker exec -it master /bin/bash
    [sudo] password for hduser: 
     * Starting OpenBSD Secure Shell server sshd                             [ OK ] 
    root@master:/# 
3. 在容器与主机之间复制文件
root@hadoop:/var/lib/docker/aufs/mnt# sudo docker cp --help

Usage:  docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
    docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH

Copy files/folders between a container and the local filesystem

Options:
  -L, --follow-link   Always follow symbol link in SRC_PATH
      --help          Print usage
root@hadoop:/var/lib/docker/aufs/mnt# sudo docker cp /home/hadoop/build master:/root/build
4. 容器之间网络连接
hduser@hadoop:~$ sudo docker network create hadoop
654077fe667295cf3fa63984d8f55c66404631b597d751510aa1ec034a8e66a7
hduser@hadoop:~$ sudo docker network connect master 
"docker network connect" requires exactly 2 argument(s).
See 'docker network connect --help'.

Usage:  docker network connect [OPTIONS] NETWORK CONTAINER

Connect a container to a network

hduser@hadoop:~$ sudo docker network connect hadoop master 
hduser@hadoop:~$ sudo docker network connect hadoop slave01
hduser@hadoop:~$ sudo docker network connect hadoop slave02
5. ssh免密登录
按照之前的ssh配置完成后 
ssh 免密码登陆 在已经配置ssh之后使用ssh 还要输入密码可以使用如下方法
root@slave01:~/.ssh# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
root@slave01:~/.ssh# chmod 600 ~/.ssh/authorized_keys
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/superce/article/details/79962717
个人分类: 大数据
上一篇微信小程序常用代码段
下一篇MYSQL数据库操作
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭