first commit

This commit is contained in:
momen
2021-10-21 14:57:58 +08:00
parent ba65bf40aa
commit 8184931095
572 changed files with 3165246 additions and 305 deletions

View File

@@ -0,0 +1,70 @@
docker使用笔记
----------------------
基础
`docker ps -a` 查看容器列表
`docker ps `查看正在运行的容器
`exit` 退出容器
`docker start <docker container id>` 启动一个已停止的容器
`docker stop <容器id>`停止容器
`docker restart <容器id>`重启容器
```bash
进入容器的两个命令
exec命名
docker exec -it <容器id> /bin/bash
attach命令退出后会终止容器
docker attach <容器id>
```
`docker rm -f <容器id>`删除容器
---------------------------------------------------------
进阶
`docker container prune`删除所有容器
> 镜像操作
>
> `docker images`列出本机镜像
>
> ```bash
> rocket.chat <none> 30f3e81eb8ad 6 months ago 816MB
> rocket.chat <none> 077d87f42281 6 months ago 816MB
> rocket.chat <none> 666b6ddfd746 6 months ago 816MB
> rocket.chat 3.10.5 63bd37a1c5e9 8 months ago 816MB
> mongo 4.0 5323653a5708 8 months ago 427MB
> cppla/serverstatus latest 84b2fc1b9a79 15 months ago 133MB
>
> ```
>
> `docker run -t -i mongo:4.0 /bin/bash`使用mongo4.0运行容器不加tag默认latest
>
> `docker search [容器名]`寻找镜像
>
> `docker pull [容器名]`下载容器镜像
>
> `docker rmi [容器名]`删除镜像
> 映射操作
>
> 端口映射
>
> docker run -d -P [image] [command]
>
>

View File

@@ -0,0 +1,142 @@
查看当前是没有swap的
```bash
$ free -m
total used free shared buffers cached
Mem: 498 310 187 0 17 170
-/+ buffers/cache: 122 375
Swap: 0 0 0
$ sudo df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/xvda1 ext4 20G 3.7G 16G 20% /
tmpfs tmpfs 250M 0 250M 0% /dev/shm
```
我们将swap挂载到/var下
$ sudo dd if=/dev/zero of=/var/swap bs=1M count=2048
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 47.8375 s, 44.9 MB/s
$ sudo mkswap /var/swap
$ sudo chmod 0600 /var/swap
$ sudo swapon /var/swap
挂载完毕后查看内存使用情况。发现swap出现了。
[root@iZ23zvh0w6mZ lnmp1.1-full]# free -m
total used free shared buffers cached
Mem: 498 456 41 0 10 100
-/+ buffers/cache: 346 152
Swap: 2047 0 2047
okswap已经可以使用了接下来我们要将swap开机自动挂载。
编辑/etc/fstab文件
$ sudo vi /etc/fstab
\#
\# /etc/fstab
\# Created by anaconda on Mon Aug 11 16:27:41 2014
\#
\# Accessible filesystems, by reference, are maintained under '/dev/disk'
\# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
\#
UUID=e76a7b8d-20c2-4f94-bdd1-f4054a34c206 / ext4 defaults,barrier=0 1 1
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
none /proc/xen xenfs defaults 0 0
/var/swap swap swap defaults 0 0
因为阿里云默认是不让用户使用swap的貌似现在的系统模版更新了这一行新装系统都没有了如果没有请忽略此步。
编辑/etc/rc.d/rc.local文件将文件中的swapoff行注释或删掉。
$ sudo vi /etc/rc.d/rc.local
\#!/bin/sh
\#
\# This script will be executed *after* all the other init scripts.
\# You can put your own initialization stuff in here if you don't
\# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
ulimit -SHn 65535
\#swapoff -a //加上"#"号注释掉或者直接删除