Category: Web

stuff about web design, development, trends, and tricks

  • Docker Cheat-sheet

    Docker Cheat-sheet

    Some semi-random commands for Docker.

    Image commands:

    docker --help #to list all commands
    sudo docker images -a -q #return just the ID of all images
    sudo docker rmi <image name> #to remove a specific image

    Working with containers:

    sudo docker ps -a -q #return just the ID of all containers
    sudo docker rm <container name or ID> #to remove specific container

    The one’s that I needed while working with Azure:

    docker login m1dev.azurecr.io --username 00000000-0000-0000-0000-000000000000 --password $TOKEN
    az acr login --name m1devcr

    *** if this fails, try to clear account on server

    Az account clear

    –goto directy with docker file and run?

    sudo docker build -t <acr service name>/<acr repo>/<image name>:<image tag> <Path to dockerfile>
    #i.e. - sudo docker build -t m1dev.azurecr.io/path/portal:version.R21.0.10 portal

    –tag is version number, might be in helm chart

    docker push <acr service name>/<acr repo>/<image name>:<image tag>

    Found this fix for build failure with copying too many files in a row – https://stackoverflow.com/questions/51115856/docker-failed-to-export-image-failed-to-create-image-failed-to-get-layer

    DOCKER_BUILDKIT=1 docker build --tag app:test 

    –used build.sh provided and then these:

    docker tag /data/portal:latest m1dev.azurecr.io/path/portal:version.R21.0.10
    docker push m1dev.azurecr.io/path/portal:version.R21.0.10

    https://docs.docker.com/engine/reference/commandline

    docker system prune  --all

    Pull from another repo-

    #put your password in a file and then run the login command, reading the file

    nano ~/my_password.txt
    cat ~/my_password.txt | sudo docker login -u TIdev1 --password-stdin TIdev1.azurecr.io

    #the list of images to pull from another repo-

    sudo docker pull TIdev1.azurecr.io/path/analytics/api -a
    sudo docker pull TIdev1.azurecr.io/path/analytics/bootstrap -a
    sudo docker pull TIdev1.azurecr.io/path/analytics/web -a
    sudo docker pull TIdev1.azurecr.io/path/data/mysql-client -a
  • Linux Cheat-sheet

    Linux Cheat-sheet

    As I get into Linux a little more and learn some handy commands, I’m going to document them here.

    ssh user@server -m [algorithm] Sometimes when reaching from Windows into Linux you need to force agreement on the security algorithm both sides are using

    ssh -Q mac to query what security algorithm are available

    nano –linenumbers [file name] text editor

    df -h to get list of folders and space in Linux

    fdisk -l to get disk info

    du -ah to get disk usage for all files and directory

    du -sh for current directory

    chmod 755 [file_name] grant most everything rights

    Ln -s [file or dir name] make symbolic link

    unlink [file or dir name] remove symbolic link

    rm -d to remove directory

    rm -dr to remove not empty directory

    history | grep [search term] -A 10 -B 10 ### search history and show the 10 lines before and after

    ls -a or -ll to list all files and folders with more details, or hidden ones

    ip -c a to get a list of network interfaces in color!

    sudo ip addr add [server IP]/24 dev [interface name] set the interface to use given IP, needs the following to turn on

    ip link set dev [interface name] up or down, to turn on or off a network interface

    ip route add default via [gateway IP] dev [interface name] sets default route to gateway

    sudo nano /etc/systemd/resolved.conf, scroll down and un-comment or amend “DNS=” line to add the DNS servers you need. Will have to restart service with sudo systemctl restart systemd-resolved

    sudo nano .bashrc (from home directory), scroll down to line 46 or so and un-comment the force_color_prompt line to get colored terminal output. You will have to logout/login to get the change.

  • Migrating Unifi Controller

    I have a VM at home that runs Windows 2008 and I put the Ubiquiti controller on it and stood up first one and then another AP to provide wireless all over my house.

    For obvious reasons I need to move away from Windows 2008 and looking at the resources on my host, thought moving the controller to a small Linux server. It would be dedicated to the controller and not any other tasks like I was using Windows for. This also allows me to learn a little more about Linux, so two birds, one stone.

    First I looked at getting an appliance. But this didn’t allow me the learning opportunity I wanted.

    Next, I tried about 5 different distros and some were extremely fast and lightweight! Bodhi linux was suggested as small and light, still with a GUI, but it was a little to odd for me to get working. Second I tried Lubuntu, again with a lightweight footprint and GUI. Again I couldn’t get all the parts working as desired. The fastest response I got was using TinyCore linux. A minimal GUI and the way applications are used threw me off.

    In the end, I just went with server version of Ubuntu. There were more distro’s suggested but all used the server install underneath; I might as well go to the source! I just had to figure out YAML for the networking and I was off and running.

    Unfortunately, I was still missing something to get the controller software downloaded and operational. Perhaps it was something I was mis-translating from doing this on a Raspberry Pi. I found a middle ground where there was a script to do most of the work, but it also was missing some parts.

    Finally! I found this script (thanks Glenn!) that covered all the needed parts and matched my distro! Ran this and my new controller came right up! Now the step of migrating the AP from one controller to the next.

    In the end, you just restore a backup of the old controller, after turning it off. The new controller picks up the AP and all other settings. Works like a dream!

    Hopefully this helps you too.