joppot

コピペで絶対動く。説明を妥協しない

プログラミング

I created docker shortcut command with bash alias

投稿日:


Abstract

Hello everyone it’s me candle.
I will introduce easy operation of the docker command.
Of course, I just created it thinking that it was useful, so please change it for much more useful.


Precondition

You use bash. ( Even though you use zsh or csh or something else, you edit a bit, it will work well)
You use docker

The list of alias

Open the .bash_profile in the home dicretory and write this.

# stop the running containers. You would pass the running container ids.
# ex) dcstop 5c07dab43333 30jfeodd
function dcstop(){
  docker stop $@
}

# stop all containers
alias dcstopa='docker stop $(docker ps -a -q)'

# remove the stopped containers. You would pass the stopped container ids.
# ex) dcrm 5c07dab43333 30jfeodd999
function dcrm(){
  docker rm $@
}

# remove all stopped containers
alias dcrma='docker rm $(docker ps -qf "status=exited") $(docker ps -qf "status=created")'

# stop and remove all containers
alias dcdel='dcstopa && dcrma'

# show running containers
alias dcps='docker ps'

# show all containers
alias dcpsa='docker ps -a'

# show stopped containers
alias dcpss='docker ps -f "status=exited"'

# docker-compose up
alias dcup='docker-compose up -d'

# docker-compose down -v
alias dcdown='docker-compose down -v'

# show all docker images
alias dci='docker images'

# remove some images. You would pass the image ids.
# ex) dcrmi d266fc618ebc 37bf53c81f1c
function dcrmi(){
  docker rmi $@
}

# remove latest created images
function dcrmli(){
  dcrmi $(docker images -q | awk 'NR == 1 {print $0}')
}

# show all docker volulmes
alias dcvls='docker volume ls'

# remove some volumes. You would pass the volume names.
# ex) dcvrm php-fpm nginx 3452380
function dcvrm(){
  docker volume rm $@
}

# login to the running container. You would pass the running container id.
# ex) dcexec 5c07dab43333
function dcexec(){
  docker exec -t -i $1 /bin/bash
}

# show cotainer logs. You would pass the container id
# ex) dclogs 5c07dab43333
function dclogs(){
  docker logs $1
}

# watching cotainer logs. You would pass the container id
# ex) dctail 5c07dab43333
function dctail(){
  docker logs -f $1
}


Conclusion

If you have any opinion, I’d appreciate if you would comment it with a comment field.

スポンサードリンク

If you think this article is good, share it please

-プログラミング
-,

執筆者:


comment

Your email address will not be published. Required fields are marked *

関連記事

Customize wordpress bogo plugin’s short code

English 日本語 Abstract Hello everyone, It’s me candle. In this time, I will show you how to customize wordpress bogo short code. The items to introduce are these. The flag display or hide Change the text Related article How to change the language form “en-US” to “en” by wordpres bogo Precondition WordPress bogo has been installed You can edit the theme of wordpress

How to fix the background scroll of react-modal

Abstract Hello everyone it’s me candle. This time I will solve the react-modal background moving problem when you scroll. Condition You use react Completed sample code If you want to run the sample code actually, you would need to install two libraries before. faker is installed for dummy data generation. yarn add faker react-modal First, I will write the sample code of the completed version. This is described in src/App.js. import React, { Component } from 'react' import Faker from 'faker' import Modal from 'react-modal' Modal.setAppElement('#root') class App extends Component { constructor(props) { super(props) this.state = { users: [], user: …

4 functions of scikit-learn preprocesses data such as machine learning

Abstract Hello every one this is candle. In this time we will prreprocess a data with scikit-learn which is machine learning library of python. We will use scikit-learn called With scikit-learn you can use what is called a converter, and you can convert the input data with fit_transform () method.Since there are many converters, I will introduce the following four converters that are often used in machine learning. Imputer StandardScaler MinMaxScaler OneHotEncorder Condition Python3 scikit-learn 0.19.1 For running sample code, you need numpy aside from these libs.

Create the simplest drop down menu in React

Abstract Hello everyone it’s me candle. In this time we will make a most simple drop down menu. Condition Knowledge of react Preparation We create a react project with the below command. create-react-app hello-menu Open src/App.js and write this. import React, { Component } from 'react' class App extends Component { render() { return ( <div> <p>hello menu</p> </div> ) } } export default App Create a components directory in the src directory. mkdir src/components Create a DropDownMenu.js file in the src/components directory. touch src/components/DropDownMenu.js Now on ready. Create a Drop down menu Open the src/components/DropDownMenu.js and write these. import …

Tutorial to create a modal using react-modal

Abstract Hello everyone it’s me candle. In this time, let’s create a modal with react-modal. React-modal is a library which can create and handle a modal easily. But However, react-modal is not easy if you try to actually use it. it is necessary to incorporate state management, action, design etc. In this article, I will explain it like a tutorial and we will make a modal together. Condition You have a react knowledge. You installed create-react-app. Set up development env If you already have a some react project, you would use it. Otherwise, you don’t have a any project, please …


I work in the venture company as a CTO. I start to write program in University, first I learned java, C++ and PHP. In the company, I'm developing web services by Rails. I do like to automation.