常用记录

1.golang 开发环境 docker命令  golang容器链接mysql容器和redis容器  redis容器导出三个端口  6379 16379 26379 

docker run --name golang --rm -it -p 8088:8088 --link golang_mysql:mysql --link golang_redis:redis -v $HOME/code/go/src:/go/src yin5th/golang

  

2.连接mysql容器时,host用命令:docker inspect 容器名 查看

yin5th@yin5th:~/code/docker/compose-golang$ docker inspect compose-golang_mysql_1 | grep IPAddress
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "172.22.0.2",
yin5th@yin5th:~/code/docker/compose-golang$ 

  

如果无法连接,可能需要开启远程访问权限。

    a.docker exec -it mysql容器名 /bin/bash

    b.mysql -uroot -p 

    c.进入mysql数据库(use mysql;)执行下列命令: (赋予root用户所有ip连接数据库的权限)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

  

mysql> flush privileges; 

 

如果mysql版本是8.0以上在授权的语句中需要去掉 IDENTIFIED BY ‘password’;否则会报语法错误

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'  WITH GRANT OPTION;

  

mysql 8.0中,第一次创建用户时,可能会报错

ERROR 1146 (42S02): Table 'mysql.role_edges' doesn't exist

需要退出mysql执行:

sudo mysql_upgrade -uroot -p

  

3.vue容器在docker中使用

docker image:docker pull ebiven/vue-cli

~/.bashrc  别名

  

在命令行下直接使用vue npm node进行相关操作。如:

通过vue-cli创建一个vue项目:

vue create vue-example

  

运行vue:

cd vue-example && npm run serve

  

shadowsocks:

sudo sslocal -c ~/shawdowsocks.json -d start

  

windows下使用docker 进入容器注意事项 后面不是跟/bin/bash 直接bash

winpty docker exec -it golang bash

  

 

posted on 2018-08-07 15:58  拙言者  阅读(182)  评论(0编辑  收藏  举报

导航