docker学习记录

ubuntu安装

sudo apt-get update
sudo apt-get install docker.io

daocloud安装(推荐安装方式)

curl -sSL https://get.daocloud.io/docker | sh(新版本,速度快)
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://cbbed681.m.daocloud.io

镜像操作

sudo docker search redis
sudo docker pull redis
sudo docker images
sudo docker rmi image-id
sudo docker rmi $(docker images -q)

docker run --name test-redis -d redis

docker ps
docker ps -a
sudo docker stop test-redis
sudo docker start test-redis

sudo docker run -d -p 6378:6379 --name port-redis redis
sudo docker rm container-id
sudo docker rm $(docker ps -a -q)
sudo docker logs container-id

sudo docker exec -it container-id/container-name bash

Oracle

sudo docker pull wnameless/oracle-xe-11g
sudo docker run -d -p 9090:8080 -p 1521:1521 -e ORACLE_ALLOW_REMOTE=true wnameless/oracle-xe-11g

mysql

sudo docker pull mysql:5.6
docker run -p 3306:3306 --name mymysql -v $PWD/conf/my.cnf:/etc/mysql/my.cnf -v $PWD/logs:/logs -v $PWD/data:/mysql_data -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6

  • -p 3306:3306:将容器的3306端口映射到主机的3306端口
  • -v $PWD/conf/my.cnf:/etc/mysql/my.cnf:将主机当前目录下的conf/my.cnf挂载到容器的/etc/mysql/my.cnf
  • -v $PWD/logs:/logs:将主机当前目录下的logs目录挂载到容器的/logs
  • -v $PWD/data:/mysql_data:将主机当前目录下的data目录挂载到容器的/mysql_data
  • -e MYSQL_ROOT_PASSWORD=123456:初始化root用户的密码

你可能感兴趣的:(docker学习记录)