docker

  1. 创建一个linux环境:基于Ubuntu,然后安装一些软件

1)docker run -i -t ubuntu /bin/bash --------创建并登录一个 ubuntu 环境
2)apt-get update --------------更新 apt-get 软件
3)root@6aad6c39f6af:/# g++
bash: g++: command not found --------没有c++编译器
4)root@6aad6c39f6af:/# vim helloworld.cpp
bash: vim: command not found --------没有vim编辑器
5) apt-get install g++ -y --------安装g++编译器-------
6) apt install vim -y --------安装vim编辑器-------
7) apt install gcc -y --------安装C语言编译器------
8)apt install gdb -y --------安装C语言调试器-------
9) apt install net-tools -y --------安装net-tools 后就可以使用 ifconfig 查看 ip地址了
10) apt-get install iputils-ping -y --------可以使用ping了
11) apt-get install procps -y -------------可以使用ps 命令了
12)apt-get install telnet -y -------------安装telnet客户端
13) apt-get install ubuntu-make ---------安装make
14) apt-get install psmisc ---------安装pstree
15) apt-get install pstack ---------安装pstack

以上方式创建的镜像的名称:myubuntu1

注意: root@6aad6c39f6af 这个是containerId

  1. 创建一个 基于 Ubuntu的, 已经安装了 vim g++ gcc gdb 软件的镜像, 然后以这个镜像启动
    -----总是失败:The command ‘/bin/sh -c apt-get update --fix-missing && apt-get install vim --fix-missing’ returned a non-zero code: 100
    docker image build . -------这个创建完成后的image id是b85cc6907c6f, 当前目录中需要有 dockerfile
    docker image build -t myimage .

    创建完成后,运行一下
    docker run -i -t b85cc6907c6f /bin/bash


    另一种方法:启动ubutu镜像,安装vim g++ gcc gdb 软件,然后再以这个运行的container来制作镜像
    localhost:1.docker xxx$ docker commit condescending_hamilton myubuntu --------docker commit 容器的名称 image的名称
    sha256:801dc16177b108c0ff2e77a9b87b8bb3b1a234efe5aae103800a6f2cb0432909 --------新创建个的iamge的 id是:801dc16177b1

    运行测试一下:
    docker run -i -t 801dc16177b1 /bin/bash
    docker run -i -t myubuntu /bin/bash

3.解决 在docker中保存的文件 永久保留的问题

  1. docker中怎么拿到 环境变量 呢
    环境变量 好像不是在docker里面用的

  2. 进入一个正在运行的container中
    docker exec -it 4993b247f49a /bin/bash ------577210f9eddc是container id, 这个命令的意思时,进入577210f9eddc container,并执行命令/bin/bash

===========================================================================================================================================================================

  1. docker 安装jdk8
    image name : myubuntu_jdk

  2. 部署一个 spring boot 程序到 docker上,并能通过浏览器访问之
    image id: myubuntu_jdk_app

  3. 怎么访问这个APP呢?

3.弄个mysql服务器
https://www.cnblogs.com/sablier/p/11605606.html

  1. 程序 访问 mysql服务器------OK

5.搭建 redis
daocker 启动redis镜像同时设置密码 : docker run -d --name redis(容器名称) -p 6379:6379 redis(镜像名称) --requirepass “xxxxxx”

参数解释: -d : 后台运行 -p 端口映射 --requirepass:xxxxx密码

6.搭建 kafka----OK,需要先搭建一个zookeeper环境,再搭建kafka环境

  1. 搭建前后端分离项目

8 完整集成

===========================================================================================================================================================================

  1. docker 网络原理

===========================================================================================================================================================================

  1. 管理

-1) docker --help

  1. docker exec --help
    这个可以查看各个命令的使用方法

1)列举本地images
docker images

2)删除本地image
docker image rm xxx

3)列举本地containers
docker container ls -a

4)删除本地containers
docker container rm 3d9eca4ee857 ----container id

===========================================================================================================================================================================

Could not attach to process. If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope,
or try
again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
(gdb) exit

cat /proc/sys/kernel/yama/ptrace_scope
tail -3 /etc/sysctl.d/10-ptrace.conf

// 用这种方法解决:
http://www.igoodtv.com/p/1065854.html
docker exec --privileged -ti 4993b247f49a /bin/bash

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值