Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker相关 #114

Open
itgoyo opened this issue Jan 2, 2019 · 5 comments
Open

Docker相关 #114

itgoyo opened this issue Jan 2, 2019 · 5 comments

Comments

@itgoyo
Copy link
Owner

itgoyo commented Jan 2, 2019

docker run --name tomcat -p 8080:8080 -v $PWD/test:/usr/local/tomcat/webapps/test -d tomcat

当前目录:容器目录

docker run -> name is already in use by container

docker ps -l查看当前的所有容器,如果有重名的可以先使用docker rm id

但要记得rm之前要先stop

命令说明:

-p 8080:8080:将容器的8080端口映射到主机的8080端口

-v $PWD/test:/usr/local/tomcat/webapps/test:将主机中当前目录下的test挂载到容器的/test

@itgoyo
Copy link
Owner Author

itgoyo commented Jan 2, 2019

**docker exec :**在运行的容器中执行命令

语法

docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

OPTIONS说明:

  • **-d :**分离模式: 在后台运行

  • **-i :**即使没有附加也保持STDIN 打开

  • **-t :**分配一个伪终端

实例

在容器mynginx中以交互模式执行容器内/root/runoob.sh脚本

runoob@runoob:~$ docker exec -it mynginx /bin/sh /root/runoob.sh
http://www.runoob.com/

在容器mynginx中开启一个交互模式的终端

runoob@runoob:~$ docker exec -i -t mynginx /bin/bash
root@b1a0703e41e7:/#

@itgoyo
Copy link
Owner Author

itgoyo commented Jan 2, 2019

docker run --name tomcat -p 8080:8080 -v $PWD/test:/usr/local/tomcat/webapps/test -d tomcat

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 run -p 3306:3306 --name mymysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql

docker mysql 密码 ABC123*&^

172.17.0.1

docker-machine env itgoyo

192.168.99.100

docker-machine ssh itgoyo

docker exec -it f163f6e95096 bash

mysql允许远程登录
GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;

my-secret-pw

docker run --name dockermysql -p 3307:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql

docker run --name dockermysql -p 3307:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.7.23


注意尽量不要使用3306换其他的端口

@itgoyo
Copy link
Owner Author

itgoyo commented Jan 2, 2019

docker run --name dockermysql -p 3307:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.7.23

搞了一个早上都没有结果、后面这个命令先命名后映射端口号就可以成功连接了。

@itgoyo
Copy link
Owner Author

itgoyo commented Jan 2, 2019

将主机./RS-MapReduce目录拷贝到容器30026605dcfe的/home/cloudera目录下。

docker cp RS-MapReduce 30026605dcfe:/home/cloudera

将容器

30026605dcfe的/home/cloudera/RS-MapReduce目录拷贝到主机的/tmp目录中。
docker cp  30026605dcfe:/home/cloudera/RS-MapReduce /tmp/
docker cp /Users/itgoyo/Documents/docker_file 5d2e100a9e10:/

@itgoyo
Copy link
Owner Author

itgoyo commented Jan 4, 2019

/usr/sbin/netdata

运行netdata

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant