Uly.me

cloud engineer

  • Home
  • About
  • Archives
Home/Archives for docker

July 4, 2019

Docker Stop and Remove All

Here’s the command to stop and remove all Docker containers.

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

docker stop $(docker ps -a -q) docker rm $(docker ps -a -q)

February 10, 2019

Run Docker Without Sudo

Run Docker without sudo. Add user to docker group. Login as docker using newgrp.

sudo gpasswd -a $user docker
newgrp docker

sudo gpasswd -a $user docker newgrp docker

You can now run the following commands without sudo.

docker ps
docker images

docker ps docker images

Every time you open a new terminal , just run.

newgrp docker

newgrp docker

May 24, 2017

SSH To A Docker Container

Docker containers are awesome. Docker allows you to quickly create development environments in a matter of minutes. Docker gives you the ability to package, ship and share your docker image to anyone. Once your docker image is on the Docker repository, anyone can pull it down and run it on their own operating system.

To keep track of running containers on your system, you can type ‘docker ps -a’ on your terminal.

$ docker ps -a
# gives a result similar to this ...
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
f322d2370415        moul/icecast        "/start.sh"              2 hours ago         Up 2 hours          0.0.0.0:8000->8000/tcp   icecast_icecast_1

$ docker ps -a # gives a result similar to this ... CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f322d2370415 moul/icecast "/start.sh" 2 hours ago Up 2 hours 0.0.0.0:8000->8000/tcp icecast_icecast_1

If you would like to SSH to a running Docker container, just run the following from the terminal.

docker exec -t -i f322d2370415 /bin/bash
# it will take you to this ... 
root@f322d2370415:/#

docker exec -t -i f322d2370415 /bin/bash # it will take you to this ... root@f322d2370415:/#

f322d2370415 is the Container ID, while /bin/bash is the shell that you would like to use.

November 28, 2016

WordPress on Docker

WordPress is a content management system for running blogs or websites. Meanwhile, Docker is a software container platform for building, shipping and running applications or utilities. Since there are thousands of Docker images already built, installing an application such as WordPress is fairly easy. In this article, I will show you how to install WordPress, MySQL, PHPMyadmin in a Docker environment. First things first, install Docker. Docker is agnostic, meaning it really doesn’t matter what platform you use, whether you’re on Windows, Linux or the Mac. Download Docker Docker. Install.

Create A Project Folder

$ mkdir wordpress
$ cd wordpress

$ mkdir wordpress $ cd wordpress

Create a Docker Compose file

The docker file for composing an image is called docker-compose.yml. It’s a YAML file that contains instructions on what to do and apps to use.

$ nano docker-compose.yml

$ nano docker-compose.yml

Type in the following configuration in the YAML file. In this example, I’m telling docker to install WordPress, MySQL and PHPMyAdmin and using the following TCP ports, credentials, and volumes.

wordpress:
  image: wordpress
  links:
    - wordpress_db:mysql
  ports:
    - 8080:80
  volumes:
    - ~/Docker/wordpress/html:/var/www/html
wordpress_db:
  image: mariadb
  environment:
    MYSQL_ROOT_PASSWORD: password
phpmyadmin:
  image: corbinu/docker-phpmyadmin
  links:
    - wordpress_db:mysql
  ports:
    - 8181:80
  environment:
    MYSQL_USERNAME: root
    MYSQL_ROOT_PASSWORD: password

wordpress: image: wordpress links: - wordpress_db:mysql ports: - 8080:80 volumes: - ~/Docker/wordpress/html:/var/www/html wordpress_db: image: mariadb environment: MYSQL_ROOT_PASSWORD: password phpmyadmin: image: corbinu/docker-phpmyadmin links: - wordpress_db:mysql ports: - 8181:80 environment: MYSQL_USERNAME: root MYSQL_ROOT_PASSWORD: password

Run Docker Compose

$ docker-compose up -d

$ docker-compose up -d

The installation may take anywhere from 5-10 mins or longer. So, grab a cup of coffee.

Access WordPress

Once installed, open up your browser and access WordPress and PHPMyadmin

http://localhost:8080
http://localhost:8181

http://localhost:8080 http://localhost:8181

You can access the WordPress files from your project’s “wordpress/html” directory.

wp-docker

That’s it.

  • « Previous Page
  • 1
  • 2
  • 3
  • Cloud
  • Linux
  • Git

Copyright © 2012–2021