1.run docker command
[root@VM_0_7_centos ~]# docker run --name=postgresql-redmine -d --env='DB_NAME=redmine_production' --env='DB_USER=redmine' --env='DB_PASS=password' sameersbn/postgresql:9.4-12
e038010f4bea9d5ca08eb8b474a21757135ff49593e8cb3a6101b24cdde9ae52
[root@VM_0_7_centos ~]# docker run --name=redmine -d --link=postgresql-redmine:postgresql --publish=10083:80 --env='REDMINE_POST=10083' sameersbn/redmine:3.2.0-4
Unable to find image 'sameersbn/redmine:3.2.0-4' locally
Trying to pull repository docker.io/sameersbn/redmine ...
3.2.0-4: Pulling from docker.io/sameersbn/redmine
8387d9ff0016: Already exists
3b52deaaf0ed: Already exists
4bd501fad6de: Already exists
a3ed95caeb02: Pull complete
012013682669: Already exists
16325a98f6c8: Pull complete
b7c84814a063: Pull complete
d242f6983f8d: Pull complete
8f7aa319f1e8: Pull complete
0085fca6a23b: Pull complete
b48b8dd1efcd: Pull complete
Digest: sha256:3df4b64773a022cb7920d7a04e2303ada7385c5549db9f069d20267590f33a50
Status: Downloaded newer image for docker.io/sameersbn/redmine:3.2.0-4
e92b61cf18c7807b3817a11951fb4742d4e6a44f70a85806c05db12d4dc18476
2.view docker images and port
[root@VM_0_7_centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/wordpress latest 9414c91da9a8 9 days ago 408 MB
docker.io/sameersbn/gitlab latest 50237d0663bd 11 days ago 2.09 GB
docker.io/gitlab/gitlab-ce latest d87e1ba8aa5f 13 days ago 1.46 GB
docker.io/sameersbn/redis latest ad607f019b8c 2 weeks ago 84.8 MB
docker.io/mariadb latest 2c73b3262fff 2 weeks ago 363 MB
docker.io/hello-world latest 2cb0d9787c4d 4 weeks ago 1.85 kB
docker.io/sameersbn/gitlab 8.4.4 9d1069e2b30c 2 years ago 720 MB
docker.io/sameersbn/redmine 3.2.0-4 7eb43870e9c7 2 years ago 636 MB
docker.io/sameersbn/postgresql 9.4-12 a100f2a18ec3 2 years ago 231 MB
[root@VM_0_7_centos ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e92b61cf18c7 sameersbn/redmine:3.2.0-4 "/sbin/entrypoint...." 2 minutes ago Up About a minute 443/tcp, 0.0.0.0:10083->80/tcp redmine
e038010f4bea sameersbn/postgresql:9.4-12 "/sbin/entrypoint.sh" 23 minutes ago Up 23 minutes 5432/tcp postgresql-redmine
c23102334507 sameersbn/gitlab:8.4.4 "/sbin/entrypoint...." 6 hours ago Up 6 hours 443/tcp, 0.0.0.0:10022->22/tcp, 0.0.0.0:10080->80/tcp gitlab
511be91cca0a sameersbn/redis:latest "/sbin/entrypoint.sh" 7 hours ago Up 7 hours 6379/tcp gitlab-redis
e9bba5e833b6 sameersbn/postgresql:9.4-12 "/sbin/entrypoint.sh" 7 hours ago Up 7 hours 5432/tcp gitlab-postgre-sql
8001906c5274 wordpress "docker-entrypoint..." 8 hours ago Up 8 hours 0.0.0.0:8080->80/tcp MyWordPress
da706ccdc499 mariadb "docker-entrypoint..." 8 hours ago Up 8 hours 3306/tcp db
a650e5202d27 hello-world "/hello" 8 hours ago Exited (0) 8 hours ago thirsty_carson
3f42d867d0ba hello-world "/hello" 8 hours ago Exited (0) 8 hours ago peaceful_euclid
netstat -tlnp
[root@VM_0_7_centos ~]# netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 827/httpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 828/sshd
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 14453/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 10745/zabbix_server
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1219/mysqld
tcp6 0 0 :::111 :::* LISTEN 10815/rpcbind
tcp6 0 0 :::8080 :::* LISTEN 11164/docker-proxy-
tcp6 0 0 :::3000 :::* LISTEN 10278/grafana-serve
tcp6 0 0 :::10080 :::* LISTEN 23918/docker-proxy-
tcp6 0 0 :::10050 :::* LISTEN 14453/zabbix_agentd
tcp6 0 0 :::10083 :::* LISTEN 31979/docker-proxy-
tcp6 0 0 :::10051 :::* LISTEN 10745/zabbix_server
tcp6 0 0 :::10022 :::* LISTEN 23928/docker-proxy-
3.access url
url:http://ip:10083/
user:admin
password:admin
使用docker-compose管理
例如:使用Docker Compose来管理redmine项目,编写.yml file
[root@VM_0_7_centos redmine]# cat docker-compose.yml
postgresql:
image: sameersbn/postgresql:9.4-12
environment:
- DB_NAME=redmine_production
- DB_USER=redmine
- DB_PASS=password
redmine:
image: sameersbn/redmine:3.2.0-4
links:
- postgresql:postgresql
ports:
- "10083:80"
environment:
- REDMINE_POST=10083
[root@VM_0_7_centos redmine]# pwd
/root/redmine
[root@VM_0_7_centos redmine]#
执行新容器组的创建和启动。
[root@VM_0_7_centos redmine]# docker-compose up -d
[root@VM_0_7_centos redmine]# docker-compose start
Starting postgresql ... done
Starting redmine ... done
[root@VM_0_7_centos redmine]# docker-compose stop
Stopping redmine_redmine_1 ... done
Stopping redmine_postgresql_1 ... done
[root@VM_0_7_centos redmine]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f3e8083dc3d5 sameersbn/redmine:3.2.0-4 "/sbin/entrypoint...." About a minute ago Exited (137) 5 seconds ago redmine_redmine_1
303f49fbe4b7 sameersbn/postgresql:9.4-12 "/sbin/entrypoint.sh" About a minute ago Exited (0) 3 seconds ago redmine_postgresql_1