标签:taobao disable 命令 nginx container 目录 pen 自启 native
SSH连接服务器:
安装Docker:
yum -y install docker-io
启动docker
service docker start
开机自启
systemctl enable docker.service
启动自带helloworld测试
docker run hello-world
安装java镜像:
docker pull java:8u111
查看已安装镜像
docker images
查找:
docker search mysql
下载
docker pull docker.io./mysql
关闭原运行的Mariadb 没有忽列(端口占用)
systemctl stop mariadb.service
systemctl disable
mariadb.service
运行容器
docker run -p 3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql
-p 3306:3306:将容器的 3306 端口映射到主机的 3306 端口。 -v -v $PWD/conf:/etc/mysql/conf.d:将主机当前目录下的 conf/my.cnf 挂载到容器的 /etc/mysql/my.cnf。 -v $PWD/logs:/logs:将主机当前目录下的 logs 目录挂载到容器的 /logs。 -v $PWD/data:/var/lib/mysql :将主机当前目录下的data目录挂载到容器的 /var/lib/mysql 。 -e MYSQL_ROOT_PASSWORD=123456:初始化 root 用户的密码
发现容器重名:重命名或者删除
删除:
重新运行:
docker run -p 3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql
成功:
进入容器:
docker exec -it mymysql bash
登入mysql:密码为上面创建容器是设置的密码
mysql -u root -p
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘mike‘;
添加远程登录用户
CREATE USER ‘mike‘@‘%‘ IDENTIFIED WITH mysql_native_password BY ‘mike‘; GRANT ALL PRIVILEGES ON *.* TO ‘mike‘@‘%‘;
退出容器:
ctrl+p+q
即可本地连接将数据导入数据库
查找
docker search nginx
安装:
docker pull docker.io/nginx
查看
运行容器:
docker run -p 80:80 --name mynginx -v $PWD/www:/www -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf -v $PWD/logs:/wwwlogs -d nginx
命令说明: -p 80:80:将容器的80端口映射到主机的80端口 --name mynginx:将容器命名为mynginx -v $PWD/www:/www:将主机中当前目录下的www挂载到容器的/www -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf:将主机中当前目录下的nginx.conf挂载到容器的/etc/nginx/nginx.conf -v $PWD/logs:/wwwlogs:将主机中当前目录下的logs挂载到容器的/wwwlogs
出现错误:
/usr/bin/docker-current: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:364: container init caused \"rootfs_linux.go:54: mounting \\\"/etc/init.d/conf/nginx.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/3f08f94209c85ac2793a07cd2e395f98f70774d7f7ccc29d168f3c0962d662b6/merged\\\" at \\\"/var/lib/docker/overlay2/3f08f94209c85ac2793a07cd2e395f98f70774d7f7ccc29d168f3c0962d662b6/merged/etc/nginx/nginx.conf\\\" caused \\\"not a directory\\\"\"" : Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.
解决方法:暂时未知
另一种启动方式:
docker run -p 8080:80 -d docker.io/nginx //将80端口映射为8080
docker ps
成功:
sudo yum install gcc gcc-c++
cd /usr/local/src
wget https://npm.taobao.org/mirrors/node/v10.13.0/node-v10.13.0.tar.gz
tar xvf node-v10.13.0.tar.gz
编译:
cd node-v10.13.0/
./configure
make
等半小时
安装:
sudo make install
查看版本:
node -v
标签:taobao disable 命令 nginx container 目录 pen 自启 native
原文地址:https://www.cnblogs.com/biaogejiushibiao/p/10402745.html